What if I also want to sort my query by group name, how should I do that? Should I go the lower level Select() way?
SELECT distinct name FROM user GROUP BY name -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Leandro Lucarella Sent: Friday, May 04, 2007 3:06 PM To: sqlobject-discuss@lists.sourceforge.net Subject: Re: [SQLObject] How do I select distinct columns? Thierry Lam, el 4 de mayo a las 14:47 me escribiste: > I'm using SQLObject 0.7.0 and I'm having lots of trouble retrieve a list > of distinct columns from my table. What is the equivalent of the following > in SQLObject? > > > > Table: users > > Columns: id, name, age > > > > SELECT distinct name FROM users > > > > The only way I can do the above is the following which uses raw sql > statement: > > > > c = users._connection > > return c.queryAll('SELECT distinct name FROM users') > > > > Is there an alternative way to do the above? An OO alternative: names = set([u.name for u in users.select()]) If you need performance, I think c.queryAll() is the way to go. -- LUCA - Leandro Lucarella - Usando Debian GNU/Linux Sid - GNU Generation ------------------------------------------------------------------------ E-Mail / JID: [EMAIL PROTECTED] GPG Fingerprint: D9E1 4545 0F4B 7928 E82C 375D 4B02 0FE0 B08B 4FB2 GPG Key: gpg --keyserver pks.lugmen.org.ar --recv-keys B08B4FB2 ------------------------------------------------------------------------ they wrap me up in the back of the trunk packed with foam and blind drunk they won't ever take me alive cause they all drive killer cars ------------------------------------------------------------------------ - 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 ------------------------------------------------------------------------- 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