Operators in mySQL query?
How do I use operators in a mySQL query? I need to say something like:
WHERE year= 2 OR year=3 OR year =4
or
WHERE year>2 AND year<4
Or is there another way to say that?
How do I use operators in a mySQL query? I need to say something like:
WHERE year= 2 OR year=3 OR year =4
or
WHERE year>2 AND year<4
Or is there another way to say that?
timjpriebe posted this at 19:52 — 9th February 2007.
He has: 2,667 posts
Joined: Dec 2004
It would work something like this...
SELECT *
FROM sometable
WHERE year >= 2
AND year <= 4
The = after the < or > makes it inclusive, rather than exclusive. With the second one you mentioned, it would only grab ones where year was 3. Assuming it was an integer and not a float, of course.
Tim
http://www.tandswebdesign.com
Megan posted this at 20:02 — 9th February 2007.
She has: 11,421 posts
Joined: Jun 1999
Okay, thanks. Sorry I left out the Select * bit - just didn't think it was relevant...
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.