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
https://forums.phpfreaks.com/topic/60342-or-statement-in-query/
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.