Jump to content

Using multiple conditions in SELECT statement


Tjk

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.