I have a users table and a friends table.
I want to get the friendships of 1 user, but getting both user info in results.
For example, let’s say I have these tables:
- users (_id_, username, firstname, lastname)
- friends (_#id1, #id2_)
Here are some data:
- users (1, foo, Foo, BAR)
(2, john, John, DOE)
- friends (1, 2)
If I query fiendship WHERE id1 = 1 OR id2 = 1, I know that with a JOIN I can get for each row, the user data. But how to get in 1 result (1 row) both users data?
1 Answer