Sos how to selec multiple roll with more one than where Sos

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
shaun112
Forum Newbie
Posts: 4
Joined: Fri Jul 04, 2008 5:38 am

Sos how to selec multiple roll with more one than where Sos

Post by shaun112 »

pleas i how can select multiple colums with the where statement.e.g
select * from tablename where name=$inputname, name=$inputname, name=$inputname,

this is the kind of sturf i want to achieve.pleas help
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Sos how to selec multiple roll with more one than where Sos

Post by califdon »

shaun112 wrote:pleas i how can select multiple colums with the where statement.e.g
select * from tablename where name=$inputname, name=$inputname, name=$inputname,

this is the kind of sturf i want to achieve.pleas help
If you want to select rows based on values in different columns, use the AND operator:

Code: Select all

SELECT * FROM tablename WHERE city=$inputcity AND country=$inputcountry AND dateofbirth < '1991-10-04'
But your example was selecting rows based on the value in just one column. For that you can use the OR operator, or you can use IN():

Code: Select all

SELECT * FROM tablename WHERE name=$inputname1 OR name=$inputname2
 
SELECT * FROM tablename WHERE name IN($inputname1, $inputname2, $inputname3)
Post Reply