Reputation: 1
This query doesn't return the expected results:
select users.username,firstname,lastname,nickname,address,mobile,email,gender
from users
where
username = (select userid from friends where friendid = 'ahmedhosni84') OR
(select friendid from friends where userid = 'ahmedhosni84');
I want to get all the information about the friends to a specified user name and get out only the first subquery and i want to get out the both sub queries
Upvotes: 0
Views: 83
Reputation: 22656
I think the syntax you're looking for is:
select users.username,firstname,lastname,nickname,address,mobile,email,gender
from users
where
username IN (select userid from friends where friendid = 'ahmedhosni84')
or
username IN (select friendid from friends where userid = 'ahmedhosni84');
Edit: Using "IN" as these return more than one result.
Upvotes: 0
Reputation: 12806
You can't do queries like (and get the desired result)
username = 'X' or 'Y'
You either have to do
username = 'X' OR username = 'Y'
Or
username IN ('X', 'Y')
Upvotes: 2