[Zope] SQL: nested select

Schmidt, Allen J. aschmidt@nvcc.edu
Mon, 19 Aug 2002 12:59:39 -0400


Depends on the DB, also.  As far as I know, MySQL does not allow sub-selects
like this. If I need something like this, I first create the query to handle
the sub-select and then include in the place with a dtml-var. Works well...

-Allen

-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
vsbabu@vsbabu.org
Sent: Monday, August 19, 2002 12:48 PM
To: Bryan C. Andregg
Cc: zope@zope.org
Subject: Re: [Zope] SQL: nested select


Hi,

Wouldn't this work?
  select * from models
    <dtml-sqlgroup where>
      <dtml-sqltest foo type=nb optional>
    <dtml-and>
      <dtml-sqltest bar type=nb optional>
    <dtml-and>
      name = (select name from users where
      uid = <dtml-sqlvar uid type=int )
    </dtml-sqlgroup>

Satheesh Babu
http://vsbabu.org/

On Mon, Aug 19, 2002 at 11:00:44AM -0400 or thereabouts, Bryan C. Andregg
wrote:
> I'm trying to generate a SQL query that includes a nested select tag,
> something like
> 
> select * from models where name =
>   ( select name from users where uid = <dtml-sqlvar uid type=int )
> 
> I can do this easily by itself, but I'd like to be able to use this with
some
> other optional parameters controled by a sqlgroup tag,
> 
> select * from models
>   <dtml-sqlgroup where>
>     <dtml-sqltest foo type=nb optional>
>   <dtml-and>
>     <dtml-sqltest bar type=nb optional>
>   <dtml-and>
>     ... My Test Here ...
>   </dtml-sqlgroup>
> 
> How does one nest that select call in the DTML?
> 
> Cheers,
> -- 
> Bryan C. Andregg		Duke University Medical Center
>  Programmer			Dept. of Anesthesiology
>  e <bryan.andregg@duke.edu>
>  p +1 919 684 6201



_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )