"Graeme B. Davis" wrote:
>
> Is it possible to have the following situation:
>
> Schema:
>
> id
> first
> last
> optional_id
>
> I want to do a select like this:
>
> SELECT D.id, D.first, D.last, D.optional_id, db1.first, db1.last
> FROM db1 AS D
> LEFT JOIN db1 ON D.optional_id=db1.id;
>
> and have it return:
>
> |id|first|last|optional_id|first|last|
> --------------------------------------
> | 1| bob | d.| NULL| NULL|NULL|
> | 2| guy | e.| 1| bob| d.|
> | 3| hrm | h.| NULL| NULL|NULL|
>
> Of course the above syntax is broken, but I was wondering if this was
> possible?
>
> Thanks!
>
> Graeme
>
Close, try:
SELECT D.id, D.first, D.last, D.optional_id, E.first, E.last
FROM dbl D
LEFT JOIN dbl E ON D.optional_id=E.id;
---------------------------------------------------------------------
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