Frank Wagner | 6 Apr 14:31
Picon

Re: select only one column, not the whole record

Sorry forgot something in my former post. See below

On Sun, Apr 6, 2008 at 2:29 PM, Frank Wagner <frank.wagner <at> nofusion.de> wrote:
Hi Daniel,

it will not be possible to achieve this with the regular SQLObject-classes. All you can do is something like this:



Yoursqlobject._connection.queryAll("select distinct ...") # hardcoded sql


or, to maintain more flexibility:

conn = Yoursqlobject._connection
conn.queryAll(conn.sqlrepr(Select(items=Yoursqlobject.q.column)))

this won´t include DISTINCT in the sql. this will:
 
results = conn.queryAll(conn.sqlrepr(Select(items=Yoursqlobject.q.column, distinct=True)))




HTH.

KR,
Frank



On Sun, Apr 6, 2008 at 7:55 AM, Daniel Fetchinson <fetchinson <at> googlemail.com> wrote:
Hi folks,

Is it possible to select only 1 column out of a table and not the
whole record? More specifically, what I really need is the following:

SELECT DISTINCT column FROM table;

The point is that I only need DISTINCT values and if I can't select 1
column only then I can't use DISTINCT because generally full records
are never the same but the value in 'column' might be repeated. So I
would need to select everything and filter through the data in python
which would be a huge performance hit.

Cheers,
Daniel

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Register now and save $200. Hurry, offer ends at 11:59 p.m.,
Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Daniel Fetchinson | 6 Apr 18:59

Re: select only one column, not the whole record

> > it will not be possible to achieve this with the regular
> > SQLObject-classes. All you can do is something like this:
> >
> > Yoursqlobject._connection.queryAll("select distinct ...") # hardcoded sql
> >
> > or, to maintain more flexibility:
> >
> > conn = Yoursqlobject._connection
> > conn.queryAll(conn.sqlrepr(Select(items=Yoursqlobject.q.column)))
>
> this won´t include DISTINCT in the sql. this will:
>
> results = conn.queryAll(conn.sqlrepr(Select(items=Yoursqlobject.q.column,
> distinct=True)))

Hi Frank, the hard coded query of course works but I'd like to have
something go through sqlobject. The Select( ) actually does the trick
of selecting only 1 column, thanks! But it does not accept 'distinct'
as a keyword argument, I wonder why.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Oleg Broytmann | 6 Apr 19:04
X-Face
Picon
Favicon

Re: select only one column, not the whole record

On Sun, Apr 06, 2008 at 09:59:56AM -0700, Daniel Fetchinson wrote:
> But it does not accept 'distinct'
> as a keyword argument, I wonder why.

   It does in SQLObject 0.10.0.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Daniel Fetchinson | 6 Apr 19:14

Re: select only one column, not the whole record

> > But it does not accept 'distinct'
> > as a keyword argument, I wonder why.
>
>    It does in SQLObject 0.10.0.

Indeed! That's great, thanks a lot!

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Gmane