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!
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.