If I understand your question, you just need to join with the languages
table twice, using aliases:

select LF.language, LT.language
    from language_pairs P, languages LF, languages LT
    where LF.id = P.from and LT.id = P.to;

> From: =?iso-8859-1?Q?Andreas_Fr=F8sting?= <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Subject: Sub-select look-alike?
> Date: Wed, 13 Mar 2002 16:12:31 +0100
>
> Hi,
>
> I have two tables:
>
>   languages:
>     id         tinyint(3) unsigned not null,
>     language   varchar(30) not null
>
>   language_pairs:
>     from       tinyint(3) unsigned not null,
>     to         tinyint(3) unsigned not null
>
> language_pairs.from and language_pairs.to are linked with languages.id
>
> (both tables are simplified in this mail and contains a lot more
> columns, but they are not relevant)
>
> Now I want to do a query giving me the names of the languages
> (languages.language) instead of language_pairs.from og .to.
>
> I can only see a solution requiring the use of sub-selects which MySQL
> doesn't (yet :) has support for.
> Anyone smarter than me who can see a solution?
>
> I want to avoid use of sub-queries if possible, and my emergency plan is
> to extract all records from `languages` into an array in PHP and simply
> use PHP to join .from and .to with the matching language. That's not in
> any way optimal, that's why I'm asking you guys :)
>
> regards,
>
> //andreas
> http://phpwizard.dk (in Danish only)



---------------------------------------------------------------------
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

Reply via email to