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 Daniel Müller <da...@gmx.de> on 2004/12/06 08:35:01 UTC

Join or Where Clause

Hello,

I have 2 tables. In one table stand numbers in the secound table stand
adresses. The have a foreign key

NumberTable
N_ID
N_Number

AdressesTable
A_ID
A_N_ID
A_Name

The adresses table have the foreign key A_N_ID=N_ID.

In the number table stand very much numbers. Now i wont to find out what
numbers in the number table are free, without a relation. I wont to build a
1:1 relation. For this I need to know what number is not set for a adress. I
have made this statement:


SELECT DISTINCT
NumberTable.N_ID,
NumberTable.N_NUMMER,
FROM
NumberTable,
AdressesTable
WHERE
AdressesTable.A_N_ID<>NumberTable.N_ID;

This statement works, but how i can create it with torque?

Or is it better if I do it with right joins?

How I do it with joins?

Thanks for help.

Daniel

-- 
NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
GMX DSL-Netzanschluss + Tarif zum superg�nstigen Komplett-Preis!

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


Re: Join or Where Clause

Posted by Stefan Clos <ma...@gmx.net>.
hi Daniel,

i would declare the Foreign Key as unique.

cheers,
Stefan


Daniel Müller schrieb:

>Hello,
>
>I have 2 tables. In one table stand numbers in the secound table stand
>adresses. The have a foreign key
>
>NumberTable
>N_ID
>N_Number
>
>AdressesTable
>A_ID
>A_N_ID
>A_Name
>
>The adresses table have the foreign key A_N_ID=N_ID.
>
>In the number table stand very much numbers. Now i wont to find out what
>numbers in the number table are free, without a relation. I wont to build a
>1:1 relation. For this I need to know what number is not set for a adress. I
>have made this statement:
>
>
>SELECT DISTINCT
>NumberTable.N_ID,
>NumberTable.N_NUMMER,
>FROM
>NumberTable,
>AdressesTable
>WHERE
>AdressesTable.A_N_ID<>NumberTable.N_ID;
>
>This statement works, but how i can create it with torque?
>
>Or is it better if I do it with right joins?
>
>How I do it with joins?
>
>Thanks for help.
>
>Daniel
>
>  
>


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


RE: Join or Where Clause

Posted by Thomas Fischer <Fi...@seitenbau.net>.




Hi,

good hack, though it only works in oracle (as far as I know)

    Thomas

a.wahhabi@free.fr schrieb am 07.12.2004 11:16:14:

> Hi all
>
> About outer join, i use a simple join and i add '(+)' :
>
> criteria.addJoin(TableMasterPeer.ID, TableSlavePeer.ID + "(+)");
>
> and it return the good information
>
> Karim
>
>
> Selon Thomas Fischer <Fi...@seitenbau.net>:
>
> >
> >
> >
> >
> >
> > Hi Daniel,
> >
> > I have looked through the source code and it seems that your query
cannot
> > be generated generically with torque. The problem is that Torque does
not
> > support join conditions other than equal (=).
> > My suggestion for a quick solution would be to use any of the methods
> > BasePeer.ExecuteQuery() and create the SQL statement "by hand".
> >
> > Yous sql statement is fine, no need to use right joins.
> >
> >    Thomas
> >
> > "Daniel Müller" <da...@gmx.de> schrieb am 06.12.2004 08:35:01:
> >
> > > Hello,
> > >
> > > I have 2 tables. In one table stand numbers in the secound table
stand
> > > adresses. The have a foreign key
> > >
> > > NumberTable
> > > N_ID
> > > N_Number
> > >
> > > AdressesTable
> > > A_ID
> > > A_N_ID
> > > A_Name
> > >
> > > The adresses table have the foreign key A_N_ID=N_ID.
> > >
> > > In the number table stand very much numbers. Now i wont to find out
what
> > > numbers in the number table are free, without a relation. I wont to
build
> > a
> > > 1:1 relation. For this I need to know what number is not set for a
> > adress. I
> > > have made this statement:
> > >
> > >
> > > SELECT DISTINCT
> > > NumberTable.N_ID,
> > > NumberTable.N_NUMMER,
> > > FROM
> > > NumberTable,
> > > AdressesTable
> > > WHERE
> > > AdressesTable.A_N_ID<>NumberTable.N_ID;
> > >
> > > This statement works, but how i can create it with torque?
> > >
> > > Or is it better if I do it with right joins?
> > >
> > > How I do it with joins?
> > >
> > > Thanks for help.
> > >
> > > Daniel
> > >
> > > --
> > > NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
> > > GMX DSL-Netzanschluss + Tarif zum supergünstigen Komplett-Preis!
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > > For additional commands, e-mail: torque-user-help@db.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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


RE: Join or Where Clause

Posted by a....@free.fr.
Hi all

About outer join, i use a simple join and i add '(+)' :

criteria.addJoin(TableMasterPeer.ID, TableSlavePeer.ID + "(+)");

and it return the good information

Karim


Selon Thomas Fischer <Fi...@seitenbau.net>:

>
>
>
>
>
> Hi Daniel,
>
> I have looked through the source code and it seems that your query cannot
> be generated generically with torque. The problem is that Torque does not
> support join conditions other than equal (=).
> My suggestion for a quick solution would be to use any of the methods
> BasePeer.ExecuteQuery() and create the SQL statement "by hand".
>
> Yous sql statement is fine, no need to use right joins.
>
>    Thomas
>
> "Daniel Müller" <da...@gmx.de> schrieb am 06.12.2004 08:35:01:
>
> > Hello,
> >
> > I have 2 tables. In one table stand numbers in the secound table stand
> > adresses. The have a foreign key
> >
> > NumberTable
> > N_ID
> > N_Number
> >
> > AdressesTable
> > A_ID
> > A_N_ID
> > A_Name
> >
> > The adresses table have the foreign key A_N_ID=N_ID.
> >
> > In the number table stand very much numbers. Now i wont to find out what
> > numbers in the number table are free, without a relation. I wont to build
> a
> > 1:1 relation. For this I need to know what number is not set for a
> adress. I
> > have made this statement:
> >
> >
> > SELECT DISTINCT
> > NumberTable.N_ID,
> > NumberTable.N_NUMMER,
> > FROM
> > NumberTable,
> > AdressesTable
> > WHERE
> > AdressesTable.A_N_ID<>NumberTable.N_ID;
> >
> > This statement works, but how i can create it with torque?
> >
> > Or is it better if I do it with right joins?
> >
> > How I do it with joins?
> >
> > Thanks for help.
> >
> > Daniel
> >
> > --
> > NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
> > GMX DSL-Netzanschluss + Tarif zum supergünstigen Komplett-Preis!
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>



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


RE: Join or Where Clause

Posted by Thomas Fischer <Fi...@seitenbau.net>.




Hi Daniel,

I have looked through the source code and it seems that your query cannot
be generated generically with torque. The problem is that Torque does not
support join conditions other than equal (=).
My suggestion for a quick solution would be to use any of the methods
BasePeer.ExecuteQuery() and create the SQL statement "by hand".

Yous sql statement is fine, no need to use right joins.

   Thomas

"Daniel Müller" <da...@gmx.de> schrieb am 06.12.2004 08:35:01:

> Hello,
>
> I have 2 tables. In one table stand numbers in the secound table stand
> adresses. The have a foreign key
>
> NumberTable
> N_ID
> N_Number
>
> AdressesTable
> A_ID
> A_N_ID
> A_Name
>
> The adresses table have the foreign key A_N_ID=N_ID.
>
> In the number table stand very much numbers. Now i wont to find out what
> numbers in the number table are free, without a relation. I wont to build
a
> 1:1 relation. For this I need to know what number is not set for a
adress. I
> have made this statement:
>
>
> SELECT DISTINCT
> NumberTable.N_ID,
> NumberTable.N_NUMMER,
> FROM
> NumberTable,
> AdressesTable
> WHERE
> AdressesTable.A_N_ID<>NumberTable.N_ID;
>
> This statement works, but how i can create it with torque?
>
> Or is it better if I do it with right joins?
>
> How I do it with joins?
>
> Thanks for help.
>
> Daniel
>
> --
> NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
> GMX DSL-Netzanschluss + Tarif zum supergünstigen Komplett-Preis!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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