Re: MySQL Query - SOLVED

From: Date: Thu, 19 Jul 2001 13:20:45 +0000
Subject: Re: MySQL Query - SOLVED
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-58677@lists.php.net to get a copy of this message
Thanks! That's exactly what I was looking for = 3 ) ----- Original Message ----- From: Morten Winkler Jørgensen <madmax@mip.sdu.dk> To: Sheridan Saint-Michel <webmaster@foxjet.com> Sent: Thursday, July 19, 2001 2:56 AM Subject: Re: [PHP] MySQL Query > Hi Sheridan, > > You wrote: > > SSM> I have a table that looks like > > SSM> Name | Type | X | Y > > SSM> Foo | Ship | 9 | 29 > SSM> Bar | Base | 9 | 29 > > SSM> Is there any way I can write a query that selects > SSM> everything with Type = Base, and X and Y = Foo's X and Y? > > SSM> ie > > SSM> "Select * from table where type = Base and X = {Foo:X} and Y = {Foo:Y}"; > > This should do the trick > > SELECT * FROM table WHERE type = "base" AND > x = (SELECT x FROM table WHERE name = "foo") AND > y = (SELECT y FROM table WHERE name = "foo") > > The only drawback is that SELECT x FROM table WHERE name = "foo" > must return a single value and alike for y. So I hope that in this > example the field "name" is your primary key as that will guarantee > success. > > -- > Kind regards, > Morten Winkler > Master Student at University of Southern Denmark >

« previous php.general (#58677) next »