db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kostyantyn Shchekotykhin <Kostyantyn.Shchekotyk...@ifit.uni-klu.ac.at>
Subject Re: Torque, building Criteria for query ...
Date Fri, 27 Feb 2004 08:54:23 GMT
Hi Chris,
Criteria object doesn't support inner queries, because not all databases 
support them. So you can try something this like this, but remember that 
this solution highly depends on your database:

         Criteria criteria = new Criteria();
         criteria.setDistinct();
         criteria.addSelectColumn(YourPeer.COL1);
         criteria.add(YourPeer.COL2, "value1");
         Criteria criteria2 = new Criteria();
         criteria2.add(YourPeer2.COL1, (Object)(YourPeer2.COL1 + " NOT 
IN " + BasePeer.createQueryString(criteria)), Criteria.CUSTOM);
         YourPeer2.doSelect(criteria2);

Regards,
Kostya


Chris Joelly wrote:
> Hello!
> 
> i'm trying to build a criteria for the following selects:
> 
> i hava a table from which i want to read a column:
> 
> select distinct col1 from table1 where col2 = 'value1'
> 
> then i want to use the list with the values 'col1' in another select
> statement:
> 
> select * from table2 where col1 not in ('values from table1.col1 read
> with previous select')
> 
> are there a simple way to use Criteria for this task?
> 
> thx, Chris
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message