On 9/27/2010 9:10 AM, Ramsey, Robert L wrote:
I have a query with three subselects, all referencing the same table. I'd like
to be able to combine them into one with aliases.
Here's what I have now:
select letter_codename,
(select greek from letter_otherlanguages where letter ='A') as greek,
(select french from letter_otherlanguages where letter ='A') as french,
(select german from letter_otherlanguages where letter ='A') as german
from intl_codes where letter='A';
I'd like to replace it with:
select letter_codename,
(select greek, french, german from letter_otherlanguages where letter ='A') as
(greek, french, german)
from intl_codes where letter='A';
Don't get hung up on the tables and structures, this is just a simple example.
:) I want to use the three subselects because if I use a left join, the
processing time goes from .4 to 5 seconds.
Is this possible?
Thanks!
This should work -
SELECT ic.letter_codename, lo.greek greek, lo.french french, lo.german
german from intl_codes ic LEFT JOIN letter_otherlanguages lo on
lo.letter = ic.letter WHERE ic.letter='A';
There should also be an index on both tables where `letter` is the
leftmost element.
--
Shawn Green
MySQL Principal Technical Support Engineer
Oracle USA, Inc.
Office: Blountville, TN
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org