php - mySQL SELECT AS for multiple criteria -
i need combine these 2 queries 1:
select user1id friendid friends user2id = '$userid' union select user2id friendid friends user1id = '$userid'
then
select firstname, lastname users id = friendid (that established)
i guess mysql's union
(manual) keyword looking for.
edit due edited question:
you need subquery trying (a join
might work, more complicated):
select firstname, lastname users id in ( select user1id friendid friends user2id = '$userid' union select user2id friendid friends user1id = '$userid' )
note subqueries can cause performance issues in large tables and/or complicated queries. may want refactor subquery join
in case.
Comments
Post a Comment