Re: MySQL Query
| From: | Marcus Hartmann | Date: | Fri, 20 Jul 2001 06:26:31 +0000 |
| Subject: | Re: MySQL Query | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-58790@lists.php.net to get a copy of this message | ||
the statement should look like this:
$result = mysql_query("select * from table where type = 'Base' and x = 'x'
and
y = 'y'");
"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);
>
> I think your reasoning is a little jumbled, though. There may be some
> way to do what you want to do with one query. There usually is for the
> simple things. I'm not quite sure what you want to accomplish, though.
> HTH. :)
>
> --
> -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/
>
>