Re: MySQL Query

From: Date: Thu, 19 Jul 2001 21:38:53 +0000
Subject: Re: MySQL Query
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-58792@lists.php.net to get a copy of this message
You wrote: "Ryan Fischer" <ryan@gigabee.com> wrote in message news:01d901c1101e$9cd43220$80c93fd0@ryan... > You wrote: > > I have a table that looks like > > > > Name | Type | X | Y > > > > Foo | Ship | 9 | 29 > > Bar | Base | 9 | 29 > > > > Is there any way I can write a query that selects > > everything with Type = Base, and X and Y = Foo's X and Y? > > > > ie > > > > "Select * from table where type = Base and X = {Foo:X} and Y = > {Foo:Y}"; > > $result = mysql_query("select x, y from table where name = 'Foo'"); > $info = mysql_fetch_object($result); > $x = $info->x; > $y = $info->y; > mysql_free_result($result); > $result = mysql_query("select * from table where type = 'Base', x = 'x', > y = 'y'"); > $info = mysql_fetch_object($result); > // Use properties of $info here. > mysql_free_result($result); "Marcus Hartmann" <daMoose@daMoose.de> wrote in message news:20010719212922.33786.qmail@pb1.pair.com... the statement should look like this: > $result = mysql_query("select * from table where type = 'Base' and x = 'x' and > y = 'y'"); Oops. And I see one other mistake here, too. The query really should be: $result = mysql_query("select * from table where type = 'Base' and x = '$x' and y = '$y'"); -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/

« previous php.general (#58792) next »