how to do 'select in' operation in sqlobject
Question
I want write a SQL statement like this:
select * from 'table' t where t.id in (1,2,4)
But I don't how to using SQLObject's grammar.
Solution
Try:
from sqlobject.sqlbuilder import IN
TableClass.select(IN(TableClass.q.id, [1, 2, 4]))
This will return a SelectResults object instance. Therefore to get the list of instances you have to:
resultList = list(TableClass.select(IN(TableClass.q.id, [1, 2, 4])))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow