sql >> Base de Datos >  >> RDS >> Mysql

¿Unión distinta de mySQL?

Prueba esto:

SELECT     a.locale, c.text AS text_1, d.text AS text_2
FROM       (SELECT DISTINCT locale FROM i18n) a
CROSS JOIN table_1 b
LEFT JOIN  i18n c ON b.text_1 = c.id_i18n AND a.locale = c.locale
LEFT JOIN  i18n d ON b.text_2 = d.id_i18n AND a.locale = d.locale

Demostración de SQLFiddle

EDITAR :Esto podría funcionar mejor:

SELECT
    a.locale, b.text_1, c.text_2
FROM
    (SELECT DISTINCT locale FROM i18n) a
LEFT JOIN
(
    SELECT b.locale, b.text AS text_1
    FROM   table_1 a
    JOIN   i18n b ON a.text_1 = b.id_i18n
) b ON a.locale = b.locale
LEFT JOIN
(
    SELECT b.locale, b.text AS text_2
    FROM   table_1 a
    JOIN   i18n b ON a.text_2 = b.id_i18n
) c ON a.locale = c.locale

Demostración de SQLFiddle