forbes — 2010-12-31T04:53:49-05:00 — #1
I'm trying to build a query that excludes specific rows by their ID, but I can't get it to work. Right now, I have:
AND (id <> '4151')
Which I've tried with and without the single quotes. And in addition to which, I tried:
AND (id != '4151')
Also, I've tried:
AND (id NOT IN (4151))
And that didn't work either.
Eventually, I'll need to be able to exclude several rows at a time.
Yes, the core query works just fine.
Yes, the ID column exists.
Yes, the record also exists.
donboe — 2010-12-31T05:02:37-05:00 — #2
When using the above examples do you get errors or are the id's simply not excluded?
forbes — 2010-12-31T05:05:31-05:00 — #3
Hi! No, I don't get any errors; the row simply isn't excluded.
donboe — 2010-12-31T05:07:59-05:00 — #4
Just tried your third option and it is working for me I only left the outside brackets out:
NOT IN ( 13, 15 )
forbes — 2010-12-31T05:20:02-05:00 — #5
Which got me thinking about the brackets — I'd not placed earlier parts of the query in their own parentheses.
I freely admit that databases aren't my strong point.
All sorted now, guys.
Thanks for your help!
guido2004 — 2010-12-31T05:41:30-05:00 — #6
Which is why you should post the entire query
Glad you got your problem sorted out.
donboe — 2010-12-31T06:35:40-05:00 — #7
Good you have it sorted indeed! Have a happy new year