Jump to content

OR Statement in query


Lyleyboy

Recommended Posts

Hi all,

I am doing a league table script for a project but I cant make it do one thing I would really like. I hope there is a way.

 

If have two team names coming in from a form.

$team1 & $team2.

Basically these are entered by the users by way of saying "I want to see the fully history of these two teams" But my table has two fields home_team & away_team

 

My query at the moment is

 

 

$sql="SELECT * FROM user WHERE home_team='$team1' and away_team='$team2'";

 

 

This is fine but it only returns half the records I want. What I need is to say

 

 

 

$sql="SELECT * FROM user WHERE home_team='$team1' OR '$team2" and away_team='$team2' OR '$team1"";

 

 

I hope that made sense. Please give me a shout

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.