these are my tables:
TABLE ‘USERS’
ID NAME AGE
01 John 22
02 Gloria 27
TABLE ‘CITIES’
ID USER_ID CITY
22 01 Sacramento
23 02 Phoenix
TABLE ‘HOBBIES’
ID USER_ID HOBBY
88 01 swimming
89 01 reading
90 02 reading
Okay, so we have two fellas: John is from Sacramento and likes swimming and reading.
Gloria is from Phoenix and only likes reading.
I know how to join the first two tables:
SELECT * FROM users INNER JOIN cities ON users.id = cities.user_id
But how can I join the ‘hobbies’ table and only display users who like swimming?
Thanks a lot,
Matthias
You will just add a
JOINto the last table and add aWHEREclause