Tuesday 4 September 2018

Mysql The request does not return the expected results

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

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')

0 comments:

Post a Comment