It works fine....
thank you

regards Micha

-----Ursprungliche Nachricht-----
Von: Sammy Lau [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 22. Mai 2002 09:17
An: Spielberg Micha
Cc: [EMAIL PROTECTED]; Jonny Stendahl
Betreff: Re: AW: Subselect or other way?


You've to do a self join to get this done.

select a.id from table a, table b where a.id = b.id and a.nr=123 and
b.nr=456;


Spielberg Micha wrote:
> 
> Thats right...
> But I don't want all id's with nr=123 or nr=456.
> I want all id's with nr=123 and nr=456 and only these id's.
> 
> For Example:
> 
>   id   nr
>  -----------
>    1    123
>    1  456
>    1  678
>    2  457
>    2  897
>    2  123
>    3  123
>    3  678
>    3  456
> 
> Id 1 and id 3 have only both numbers.
> If I try your query i become id 1,2,3 and that's not that i want. I
want
> only id 1,3
> 
> regards Micha
> 
> -----Ursprüngliche Nachricht-----
> Von: Jonny Stendahl [mailto:[EMAIL PROTECTED]]
> Gesendet: Mittwoch, 22. Mai 2002 08:27
> An: Spielberg Micha; [EMAIL PROTECTED]
> Betreff: SV: Subselect or other way?
> 
> OK!
> 
> You can use SELECT DISTINCT:
> SELECT DISTINCT id
> FROM Table
> WHERE nr=123
> OR         nr=456
> 
> this gives you all uniqe id's with nr = 123 OR nr = 456 and that is id
=
> 1.
> 
> //
> Jonny
> 
> > -----Ursprungligt meddelande-----
> > Från: Spielberg Micha [SMTP:[EMAIL PROTECTED]]
> > Skickat:      den 22 maj 2002 08:13
> > Till: [EMAIL PROTECTED]; Jonny Stendahl
> > Ämne: AW: Subselect or other way?
> >
> > I think my english ist too bad....
> >
> > My table looks like this
> >
> >   id   nr
> > -----------
> >   1   123
> >   1   456
> >   1   678
> >   2   457
> >   2   897
> >   2   123
> >
> >
> > I want to select in a query only these id that have nr=123 and
nr=456.
> > In the example its only id 1.
> >
> > regards Micha
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Jonny Stendahl [mailto:[EMAIL PROTECTED]]
> > Gesendet: Mittwoch, 22. Mai 2002 07:53
> > An: Spielberg Micha; [EMAIL PROTECTED]
> > Betreff: SV: Subselect or other way?
> >
> >
> > This is a simple SELECT statement:
> >
> > SELECT id
> > FROM Table
> > WHERE nr=3D123
> > AND       id = 3D456
> >
> > this gives you probably one record, or you could use OR:
> >
> > SELECT id
> > FROM Table
> > WHERE nr=3D123
> > OR       id = 3D456
> >
> > this gives you all records with nr 3D123 OR id 3D456
> >
> > //
> > Jonny
> >
> >
> > > -----Ursprungligt meddelande-----
> > > Från:       Spielberg Micha
[SMTP:[EMAIL PROTECTED]]
> > > Skickat:    den 22 maj 2002 07:46
> > > Till:       [EMAIL PROTECTED]
> > > Ämne:       Subselect or other way?
> > >
> > > Hi,
> > >
> > > i have a table like this:
> > >
> > > Fields: id,nr
> > > I want now a query like this:
> > >  SELECT id FROM Table WHERE nr=3D123 and (SELECT id FROM Table
> > > WHERE nr=3D456).
> > >
> > > Must i do this with a temp Table or ist there any other way to do
> this
> > > with Joins?
> > >
> > > I hope someone can help me..
> > >
> > > regards Micha
> > >
> > >
> ---------------------------------------------------------------------
> > > Before posting, please check:
> > >    http://www.mysql.com/manual.php   (the manual)
> > >    http://lists.mysql.com/           (the list archive)
> > >
> > > To request this thread, e-mail
<[EMAIL PROTECTED]>
> > > To unsubscribe, e-mail
> > >
> >
>
<[EMAIL PROTECTED]>
> > > Trouble unsubscribing? Try:
> http://lists.mysql.com/php/unsubscribe.php
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-- 
Sammy Lau
mailto: [EMAIL PROTECTED]
- Tell me what you want and I'll tell you how you can live without it.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to