I have two tables:
- Users: ID, first_name, last_name
- Networks: user_id, friend_id, status
I want to select all the values from the users table, but I want to display the status of a specific user (say with id = 2), and the rest is NULL. For example: If I have users:
? first_name last_name
And in the networks:
user_id friend_id status ------------------------------ 2 1 friends
I want to do a John Smith search for all other users, so I want to get:
id first_name last_name status ------------------------------------ 2 Tom Summers friends 3 Amy Wilson NULL
I tried to make a LEFT JOIN and then WHERE, but this did not work because it excluded lines that are related to other users, but not to this user.
I can do this using the UNION instruction, but I was wondering if it is possible to do this without UNION.
source share