1

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.

Fenton
  • 241,084
  • 71
  • 387
  • 401
fangshi
  • 13
  • 3

1 Answers1

3

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])))
Joseph Victor Zammit
  • 14,760
  • 10
  • 76
  • 102
  • 1
    Great, it's ok now, thanks very much. Firstly i using select(In(id,[1,2,3,4])) ,there always return None to me . – fangshi Oct 04 '12 at 17:13