WITH card_name AS ( SELECT "index" AS id, text FROM text_data WHERE category = 75 ), chara_name AS ( SELECT "index" AS id, text FROM text_data WHERE category = 77 ), unique_name AS ( SELECT "index" AS id, text FROM text_data WHERE category = 150 ), unique_desc AS ( SELECT "index" AS id, text FROM text_data WHERE category = 155 ) SELECT sc.id, card_name.text AS card_name, sc.chara_id, chara_name.text AS chara_name, sc.rarity, sc.effect_table_id, sc.command_id, sc.support_card_type, sc.skill_set_id, sc.outing_max, IFNULL(unique_name.text, '') AS unique_name, IFNULL(unique_desc.text, '') AS unique_desc, IFNULL(u.lv, 0) AS unique_lv, IFNULL(u.type_0, 0) AS unique_type, IFNULL(u.value_0, 0) AS unique_value0, IFNULL(u.value_0_1, 0) AS unique_value0_1, IFNULL(u.value_0_2, 0) AS unique_value0_2, IFNULL(u.value_0_3, 0) AS unique_value0_3, IFNULL(u.value_0_4, 0) AS unique_value0_4, IFNULL(u.type_1, 0) AS unique_type1, IFNULL(u.value_1, 0) AS unique_value1, IFNULL(u.value_1_1, 0) AS unique_value1_1, IFNULL(u.value_1_2, 0) AS unique_value1_2, IFNULL(u.value_1_3, 0) AS unique_value1_3, IFNULL(u.value_1_4, 0) AS unique_value1_4, IFNULL(u.idle_mode_sub_rate, 0) AS idle_mode_sub_rate FROM support_card_data sc LEFT JOIN support_card_unique_effect u ON sc.unique_effect_id = u.id JOIN card_name ON sc.id = card_name.id JOIN chara_name ON sc.id = chara_name.id LEFT JOIN unique_name ON sc.unique_effect_id = unique_name.id LEFT JOIN unique_desc ON sc.unique_effect_id = unique_desc.id ORDER BY sc.id