simple mysql "or" question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

simple mysql "or" question

Post by fariquzeli »

what would be the mysql query syntax that I would use if I wanted to grab a row of informationi from a table based on whether a value is equal to 7 or 8?

would it be

$sql = "SELECT * FROM customers WHERE id = '7' OR '8'";

I don't think that is right at all but I really don't know if this is possible or not.

Thanks!
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Re: simple mysql "or" question

Post by redhair »

I would try and get 7 or 8 before the querry, and turn it in a variable.

Code: Select all

<?php
$sql = "SELECT * FROM customers WHERE id = $solution";
?>
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post by fariquzeli »

Alrighty, thanks!
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

You could also use:

Code: Select all

$sql = "SELECT * FROM customers WHERE id IN (7,8);
John M
Post Reply