On Tue, 22 Jul 2003, Larry Brown wrote:

> Table alpha:
> 
> id int(3) not null auto_increment,
> name char(12) not null,

> Table bravo:
> 
> afrom int(3) not null,
> ato int(3) not null,

> in the php variable coming in I have fred and need to run a query to get
> george.

You just need to join from alpha to bravo and then from bravo back to
alpha.  To do that you need to alias alpha with two different names
(a1 and a2, for example).  Try this:

  SELECT a2.name 
  FROM alpha AS a1, bravo AS b, alpha AS a2
  WHERE a1.name = 'fred'  AND
        a1.id   = b.afrom AND
        b.ato   = b.id;

The same thing can be done with LEFT JOIN for a little added style,
but this should work fine as-is.

-sam


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to