Can anyone help me with selecting multiple values from the attribute table?

I tried "Classes"='14'AND'07' but it doesn't work.


A more elegant solution is:

"Classes" in ('14','15',....)

| improve this answer | |
  • In case of null USE inverted commas OR NOT e.g for above code "Classes" in (NULL,'14','15',....) OR "Classes" in ('NULL','14','15',....) N.B. Only single inverted comma care it.. – SIslam Dec 29 '14 at 13:57

You would need to break up your selection statement into two separate parts:

"Classes" = '14' OR "Classes" = '07'

Edit: Changed from AND to OR, since as noted in the comments, AND cannot work in this situation.

| improve this answer | |
  • Thanks for the suggestion RyanL. The AND in the middle does not work. But the OR works. – Stan John Nov 15 '13 at 8:15
  • 11
    The AND doesn't work because you cannot have both 14 and 07 in the same field for the same feature. If you have multiple cases you want to select, use the syntax: fieldname in ('value1','value2','value3') for strings or without '' for integers. – Alex Tereshenkov Nov 15 '13 at 8:35
  • What happens if I have hundreds and hundreds of values that I want the database to search and select? In fact I have a whole CSV file worth of these values... I can't possible fit them all in the little query box using SQL... Is there a more robust solution? – user32882 Jul 11 '15 at 19:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.