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