SELECT f.language as From, t.language as To
FROM language f, language t, language_pairs lp
WHERE f.id = lp.from
  AND t.id = lp.to;

--Greg Johnson

-----Original Message-----
From: Andreas Frøsting [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 13, 2002 10:13 AM
To: [EMAIL PROTECTED]
Subject: Sub-select look-alike?


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

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