我ER_BAD_FIELD_ERROR: Unknown column 'year_fk' in 'field list'在这个查询中收到错误:
SELECT CONCAT('program:', program_pk) AS global_id, program_name AS name, NULL AS parent_global_id FROM program UNION ALL SELECT CONCAT('year:', year_pk) AS global_id, year_name AS name, CONCAT('program:', program_fk) AS parent_global_id FROM year UNION ALL SELECT CONCAT('year:', year_fk, ',unit:', unit_name) AS global_id, unit_name AS name, CONCAT('year:', year_fk) AS parent_global_id FROM unit UNION ALL SELECT CONCAT('year:', year_fk, ',unit:', unit_name, ',rotation_discipline_block:', rotation_discipline_block_name) AS global_id, rotation_discipline_block_name AS name, CONCAT('year:', year_fk, ',unit:', unit_name) AS parent_global_id FROM rotation_discipline_block rdb INNER JOIN unit u ON u.unit_pk = rdb.unit_fk UNION ALL SELECT CONCAT('year:', year_fk, ',unit:', unit_name, ',rotation_discipline_block:', rotation_discipline_block_name, ',week:', week_name) AS global_id, week_name AS name, CONCAT('year:', year_fk, ',unit:', unit_name, ',rotation_discipline_block:', rotation_discipline_block_name) AS parent_global_id FROM week UNION ALL SELECT CONCAT('year:', year_fk, ',unit:', unit_name, ',rotation_discipline_block:', rotation_discipline_block_name, ',week:', week_name, ',learning_event:', learning_event_name) AS global_id, learning_event_name AS name, CONCAT('year:', year_fk, ',unit:', unit_name, ',rotation_discipline_block:', rotation_discipline_block_name, ',week:', week_name) AS parent_global_id FROM learning_event le INNER JOIN week ON week.week_pk = le.week_fk INNER JOIN rotation_discipline_block rdb ON rdb.rotation_discipline_block_pk = le.rotation_discipline_block_fk INNER JOIN unit u ON u.unit_pk = rdb.unit_fk INNER JOIN year y ON u.year_fk = y.year_pk ORDER BY name 不确定包含year_fk的查询的哪个部分...
见db-fiddle
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。