Jump to content

Archived

This topic is now archived and is closed to further replies.

JamesRyzon

mysql Multiple statements

Recommended Posts

Having some trouble with mysql statements wanting to run multiple types at once this is an example

[code]
SELECT * FROM cars WHERE Year='$year' AND Model='Ford' OR 'GM'
[/code]

Just as an exmaple, the query only returns cars from 1990 and Ford type, skipping GM.

Any helpful hints on this?

Share this post


Link to post
Share on other sites
...AND Model='Ford' OR Model='GM'

Which could also be expressed:

...AND Model IN ('Ford', 'GM')

Share this post


Link to post
Share on other sites
Thank you for your quick reply!

That was exactily what i was looking for but I didnt know about "IN" in sql, thanks again!

Share this post


Link to post
Share on other sites
If you didn't use IN(), you should probably use parens to make it explicit.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.