PDA

View Full Version : How to query columnA or columnB="content"?


Petawa
07-29-2004, 03:31 PM
I need to do a query like the following for my ladder script. Essentially, I'm checking to see if there is already a row in the games table that was written today that involves the same people as the row they're currently trying to insert. If I get a positive result from the query on mysql_num_rows, I'll end the script with an error stating one must only post one match per opponent per day.

$query2="SELECT winner, loser, date from ladder_games where date>$yesterday and winner=($winnerid or $memnum) and loser=($winnerid or $memnum)";

So, I want it to match true if winner=$winnerid and loser=$memnum OR if winner=$memnum and loser=$winnerid.

Thanks.

raf
07-29-2004, 04:06 PM
$query2="SELECT winner, loser, date from ladder_games where date>$yesterday and ((winner=$winnerid and loser=$memnum) OR (winner=$memnum and loser=$winnerid))

although
"date>$yesterday" should better be "date=Now()"