phorcon3 Posted August 19, 2008 Share Posted August 19, 2008 ID USER1 USER2 1 test test1 2 test1 test2 3 test3 test1 5 test test3 6 test test2 7 test3 test4 i am test.. and im connected with test1.. and now i wanna check which users i have in common with test1 = test2,test3 how can i do that in one single query? to find out if im connected with test1, id have to do <?php $a=mysql_query("SELECT * FROM `table` WHERE `USER1` = 'test' AND `USER2` = 'test1' OR `USER2` = 'test' AND `USER1` = 'test1'"); ?> but how do i check which other ones (test2,test3) we have in common?...id have to use two queries again ..but maybe theres a sql func to do it with one single query.. does anyone know? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 20, 2008 Share Posted August 20, 2008 You need to join the table to itself. Quote Link to comment Share on other sites More sharing options...
phorcon3 Posted August 20, 2008 Author Share Posted August 20, 2008 thanks! it works perfectly! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.