[Zope] A single value from SQL

Rob Page rob.page@digicool.com
Sat, 5 Jun 1999 12:05:24 -0400


> What I'm really trying to do here is:
> 
> select * from some_table where some_column = (select max(some_column)
> from another_table)
> 
> but MySQL doesn't support nested selects (yet).
> 
> I'm quite confident there's a way to do this -- I was reading about
> direct traversal -- but I can't quite grasp it.

<UNTESTED>

   ZSQLMethod1
   -------------
   SELECT MAX(some_column) AS fred FROM another_table
   
   ZSQLMethod2
   -------------
   SELECT firstname, lastname, email FROM some_table WHERE some_column =
<!--#sqlvar fred type=int-->
   
   DTMLMethod1
   -------------
   
   <!--#with ZSQLMethod1-->
   
     <!--#in "ZSQLMethod2(fred=fred)"-->
   
       <!--#var lastname-->, <!--#var firstname--> <!--#var email-->
   
     <!--#/in-->

   <!--#/with-->
   
</UNTESTED>

---
I'd bet there's a way of doing _something_ like (I know I'm missing a
sequence-item in here somewhere...)  :

<!--#in "ZSQLMethod2(fred=ZSQLMethod1('fred'))"-->
<!--#/in-->

which would be more elegant if harder to read...

--Rob