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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Long sql statment

Status
Not open for further replies.

ashz

Programmer
Dec 9, 2002
43
ES
Hello,

Is there any better way to write the following statement: select * from car where model=’1’ and model=’x’ and model=’23’ model=’zx’.

Thanks.
 
You're missing one "and" or "or" near the end of the statement.

Also, that query will never return any rows. The column "model" can't be all four of those values at the same time.

Did you mean:

select * from car where model=’1’ or model=’x’ or model=’23’ or model=’zx’ Want the best answers? Ask the best questions: TANSTAAFL!
 
If you did mean "or", you can use the IN statement:

select * from car where model IN (’1’,’x’,’23’,’zx’)
--
How can you be in two places at once when you're not anywhere at all?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top