MySQL Forums
Forum List  »  Newbie

Alternative query
Posted by: Aziz
Date: July 26, 2005 11:22AM

Hi, again!

[sql]
SELECT i1.IN_ID,
(SELECT i2.resource FROM i18n i2 WHERE i2.lang='en' AND i2.in_id = i1.in_id ) as en,
(SELECT i2.resource FROM i18n i2 WHERE i2.lang='de' AND i2.in_id = i1.in_id ) as de,
(SELECT i2.resource FROM i18n i2 WHERE i2.lang='ur' AND i2.in_id = i1.in_id ) as ur
FROM i18n i1
GROUP BY i1.in_id
[/sql]

This query was suggested by a person named Finten on another (german) forum, where I first was looking for help to my problem.

The query is quite sophisticated (to my mind) and MySQL is able to optimize the GROUP BY clause away, so that only the primary key index is used to find the records (which means, no temporary table or the like is needed).

Regards.

Options: ReplyQuote


Subject
Written By
Posted
Alternative query
July 26, 2005 11:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.