CREATE VIEW idx AS SELECT DISTINCT r1.kana as main_cat_kana, r2.kana as sub_cat_kana, m.main_cat as main_cat, m.sub_cat as sub_cat, m.nombre as nombre FROM mst as m LEFT OUTER JOIN ruby as r1 ON m.main_cat = r1.kanji LEFT OUTER JOIN ruby as r2 ON m.sub_cat = r2.kanji -- ORDER BY -- main_cat_kana, sub_cat_kana, nombre ;