You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Bertrand VENZAL <be...@cirso.fr> on 2005/11/25 10:52:10 UTC

Query with Torque

Hi,

I ve got a problem to write a query with Torque with a join on the same 
table, is there a way to do it by using only one query.

My query syntax looks like that 
select DISTINCT a.* from localisation a , localisation b where 
b.loc_IR="SudOuest" and b.loc_regionAdmin=a.loc_organisme;

My table
LOCALISATION
ID      |       loc_organisme   |       loc_regionAdmin |       loc_IR |

1       |       Bordeaux        |       Aquitaine               | SudOuest 
|

2       |       Aquitaine       |       NULL                    | NULL |

My query should return the second row.

I probably miss a torque function that should allow that.

Thanks for your help
Bertrand

Re: Query with Torque

Posted by Bertrand VENZAL <be...@cirso.fr>.
Hi,

I test your soluce and it was nearly that except that the following line 
have to be rewrited
crit.addJoin(LocalisationPeer.LOC_ORGANISME, "LOCAL2".LOC_REGIONADMIN);
like that
crit.addJoin(LocalisationPeer.LOC_ORGANISME, "LOCAL2" + 
LOC_REGIONADMIN.substring(LOC_REGIONADMIN.indexOf('.'));

Thanks for your help
Bertrand





Patrick Carl <pa...@web.de> 
Envoyé par : 
torque-user-return-6601-bertrand.venzal=cirso.fr@db.apache.org
25/11/2005 19:36
Veuillez répondre à
"Apache Torque Users List" <to...@db.apache.org>


A
Apache Torque Users List <to...@db.apache.org>
cc

Objet
Re: Query with Torque






Hi,

something like the following should work:

Criteria crit = new Criteria();
crit.addAlias("LOCAL2", LocalisationPeer.TABLE_NAME);
crit.addJoin(LocalisationPeer.LOC_ORGANISME, "LOCAL2".LOC_REGIONADMIN);
crit.add(LOC_IR, "SudOuest");
LocalisationPeer.doSelect(crit);

Please have a try,

Patrick

Bertrand VENZAL schrieb:
> Hi,
> 
> I ve got a problem to write a query with Torque with a join on the same 
> table, is there a way to do it by using only one query.
> 
> My query syntax looks like that 
> select DISTINCT a.* from localisation a , localisation b where 
> b.loc_IR="SudOuest" and b.loc_regionAdmin=a.loc_organisme;
> 
> My table
> LOCALISATION
> ID      |       loc_organisme   |       loc_regionAdmin |       loc_IR |
> 
> 1       |       Bordeaux        |       Aquitaine               | 
SudOuest 
> |
> 
> 2       |       Aquitaine       |       NULL                    | NULL |
> 
> My query should return the second row.
> 
> I probably miss a torque function that should allow that.
> 
> Thanks for your help
> Bertrand

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



Re: Query with Torque

Posted by Patrick Carl <pa...@web.de>.
Hi,

something like the following should work:

Criteria crit = new Criteria();
crit.addAlias("LOCAL2", LocalisationPeer.TABLE_NAME);
crit.addJoin(LocalisationPeer.LOC_ORGANISME, "LOCAL2".LOC_REGIONADMIN);
crit.add(LOC_IR, "SudOuest");
LocalisationPeer.doSelect(crit);

Please have a try,

Patrick

Bertrand VENZAL schrieb:
> Hi,
> 
> I ve got a problem to write a query with Torque with a join on the same 
> table, is there a way to do it by using only one query.
> 
> My query syntax looks like that 
> select DISTINCT a.* from localisation a , localisation b where 
> b.loc_IR="SudOuest" and b.loc_regionAdmin=a.loc_organisme;
> 
> My table
> LOCALISATION
> ID      |       loc_organisme   |       loc_regionAdmin |       loc_IR |
> 
> 1       |       Bordeaux        |       Aquitaine               | SudOuest 
> |
> 
> 2       |       Aquitaine       |       NULL                    | NULL |
> 
> My query should return the second row.
> 
> I probably miss a torque function that should allow that.
> 
> Thanks for your help
> Bertrand

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