سؤال

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.

هل كانت مفيدة؟

المحلول

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])))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top