Jump to content

Archived

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

Tjk

Using multiple conditions in SELECT statement

Recommended Posts

I'm having a problem with this little statement and I was wondering if someone could put me right on where i'm going wrong.

[code]
$query= mysql_query("SELECT * from friend WHERE {friend1='$userid' AND friend2='$_POST[friend]'} OR {friend1='$_POST[friend] AND friend2='$userid'}")or die("could not select friends record from friends");
[/code]

I only want to select the record (and as i have it setup there can only be one record) where either the user of the page's id is in either friend1 or friend 2 and the other use that they have selected in a pulldown list is in the other friend column.

So for example if user of the page's id was 1 and the person they had selected had an id of 3 then it would select either when friend1 has the id 1 and friend2 has the id3 in it or friend1 has the id of 3 and friend 2 has the id of 1.

Hope this is clear enough for you to understand. Help appreciated as always.

-Tjk

Share this post


Link to post
Share on other sites
Looks fine to me -- but you should be using parentheses, not curlies.

Share this post


Link to post
Share on other sites

×

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.