Jump to content

query problem


squiblo

Recommended Posts

I have never attempted mysql like this before...this is what the table looks like..

 

||  user_id ||  other_person_id  ||  friend  ||  foe ||

        2                    44                      1          0

      34                      2                        1          0

 

 

What i want to do is this.... say that the $_SESSION['user_id'] == 2

 

and $user_id = $SESSION['user_id'];

 

Without doing 2 queries how can I pick put all the people that are friends with $user_id?

Link to comment
https://forums.phpfreaks.com/topic/188263-query-problem/
Share on other sites

forget that previous post, thats just be being stupid once again...i think i ment this...

 

mysql_query("SELECT * FROM table_name WHERE user_id='$user_id' OR page_zebra_id='$user_id' AND friend=1");

 

i have tried this but it only give me data from 1 row

Link to comment
https://forums.phpfreaks.com/topic/188263-query-problem/#findComment-993934
Share on other sites

an easier way of putting it, how can i merge these 2 queries into 1...

 

mysql_query("SELECT * FROM table WHERE user_id='$user_id' AND friend=1");

 

and

 

mysql_query("SELECT * FROM table WHERE other_person_id='$user_id' AND friend=1");

 

 

and then my aim is to echo out the the row that doesnt have $user_id in it

 

 

NOTE: $user_id will never been the same in both rows

 

 

Link to comment
https://forums.phpfreaks.com/topic/188263-query-problem/#findComment-993957
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.