views:

16

answers:

1

This must be super basic, but I just can't figure it out. I want to select from a table with lots of tag names all the tags who aren't part of the array 'tagnames'. I tried:

Tag.where(
  "name != ?", tagnames
)

gives me "Operand should contain 1 column(s)"

Tag.where(
  "name NOT IN ?", tagnames
)

gives me a SQL error

I know how to get all entries with the names of tagnames:

Tag.where(
  :name => tagnames
)

just not how to say this inverse... Many thanks for any help!

A: 

I think you just need to put the brackets round the ? in your "name NOT IN ?" i.e. "name NOT IN (?)". I expect that is the cause of your SQL error.

mikej
works! sorry, I am a beginner, but thanks a lot!
Thomas Traum