SQL: nested select
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
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
On Mon, Aug 19, 2002 at 12:47:50PM -0400, vsbabu@vsbabu.org mailed:
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>
This make "name" a required field or matches on '' which fails, of course. -- Bryan C. Andregg Duke University Medical Center Programmer Dept. of Anesthesiology e <bryan.andregg@duke.edu> p +1 919 684 6201
Bryan C. Andregg writes:
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 ... name = (select ...) </dtml-sqlgroup>
Dieter
participants (3)
-
Bryan C. Andregg -
Dieter Maurer -
vsbabu@vsbabu.org