I have 2 tables. Player and Stats. Player has the fields: Name, Age, DOB and SSN. Stats has the fields: Tackles, Goals, Assists, and SSN. SSN is a foreign key. How can I write a query to find the stats of players with DOB >= '1994'. DOB is not a foreign key, I was wondering how that could work.
Sql: Selecting from other tables
66 views Asked by user3078335 At
3
There are 3 answers
0
On
this is a simple Join commmand.
SELECT * FROM Stats
INNER JOIN Player
On Player.SSN = Stats.SSN
WHERE DOB > 1994
there is an issue from here however as you imply that DOB is a string, not a datetime or Integer with those quotes. you cant compare Strings as numbers like you are trying to do. if DOB is just year e.g. 1994, then DOB >= 1994
would work, if its a date
or datetime
, you need to use Datetime
equivalents.
If you just want specific fields then specify these instead of SELECT *