Hi!
I'm trying to write a query that will generate SQL like: SELECT * FROM table WHERE id IN (1, 2, 3); What I've tried without success: ================================================================================ amostras_ids = [(amostra.id) for amostra in amostras] if amostras_ids: resultados = model.VAuditoriaResultado.select( model.VAuditoriaResultado.q.amostraID in amostras_ids) ================================================================================ that results in: ================================================================================ SELECT neolab.v_auditorias_resultados.id, neolab.v_auditorias_resultados.amostra_id, neolab.v_auditorias_resultados.analise, neolab.v_auditorias_resultados.resultado, neolab.v_auditorias_resultados.incluido_por_id, neolab.v_auditorias_resultados.alterado_por_id, neolab.v_auditorias_resultados.incluido_em, neolab.v_auditorias_resultados.alterado_em FROM neolab.v_auditorias_resultados WHERE 't' ORDER BY id ================================================================================ This returns all rows, and it's not what I want. I've also tried: ================================================================================ amostras_ids = [(amostra.id) for amostra in amostras] # INSubquery comes from sqlbuilder if amostras_ids: resultados = model.VAuditoriaResultado.select(INSubquery( model.VAuditoriaResultado.q.amostraID, amostras_ids)) ================================================================================ that results in: ================================================================================ SELECT neolab.v_auditorias_resultados.id, neolab.v_auditorias_resultados.amostra_id, neolab.v_auditorias_resultados.analise, neolab.v_auditorias_resultados.resultado, neolab.v_auditorias_resultados.incluido_por_id, neolab.v_auditorias_resultados.alterado_por_id, neolab.v_auditorias_resultados.incluido_em, neolab.v_auditorias_resultados.alterado_em FROM neolab.v_auditorias_resultados WHERE neolab.v_auditorias_resultados.amostra_id IN ((10, 11, 12, 13, 14, 15, 16, 17, 1234, 1357, 50021, 50028, 123456, 123456789, 1234568970, 1235467890)) ORDER BY id ================================================================================ and is the closest result I could get. The problem, here, is that there are extra parenthesis here. The correct query would be "IN (10, 11, 12,...)". Is this query possible? I don't want to reissue the query that got this list from the server because it is somewhat expensive and it was already performed before (I'd like to avoid JOINs for known values here). Any hints on how to get this working? (I'm volunteer for more beta testing to solve this, Oleg ;-)) -- Jorge Godoy <[EMAIL PROTECTED]> ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss