Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple "WHERE's" 3

Status
Not open for further replies.

annasue

Technical User
Mar 20, 2004
21
0
0
US
I need to select two projects from my database. I have the statement:

Select * from projects WHERE `project_name` = "A New Project" && WHERE `project_name` = "John's Project"

It doesn't like that; what is the syntax for selecting multiple entries? I tried it without the second "WHERE" and it didn't like that any better.

Thanks in advance.
 
A query can only have one where clause.

But what you're trying to do is pick those records which fit any of multiple criteria.

Select * from projects WHERE `project_name` = "A New Project" or `project_name` = "John's Project"





Want the best answers? Ask the best questions!

TANSTAAFL!!
 
To me && is AND, so in addition to sleipnir's post:

SELECT * FROM projects WHERE `project_name` = "A New Project" AND `project_name` = "John's Project"

Cheers.

 
oops... sorry, I didn't see the fields... they are the same one.. the it should be OR and not AND.

Sorry again.
 
Thank you so much. The OR worked like a charm!
 
you could also use IN:
Select * from projects WHERE `project_name` IN ("A New Project","John's Project")

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top