
数据表字段

构造的SQL
SELECT * FROM ( SELECT * FROM tp5_system_history_1 UNION SELECT * FROM tp5_system_history_2 UNION SELECT * FROM tp5_system_history_3 UNION SELECT * FROM tp5_system_history_4 UNION SELECT * FROM tp5_system_history_5) AS SystemHistory WHERE `( SELECT * FROM tp5_system_history_1 UNION SELECT * FROM tp5_system_history_2 UNION SELECT * FROM tp5_system_history_3 UNION SELECT * FROM tp5_system_history_4 UNION SELECT * FROM tp5_system_history_5) AS SystemHistory`.`delete_time` IS NULL ORDER BY `sh_id` LIMIT 20这个问题不知道是BUG还是我什么地方做得不对,我感觉是软删除开启后,模型分表构造SQL的时候,直接把联合查询的语句拿过来了正确的SQL应该是
SELECT
*
FROM
(
SELECT
*
FROM
tp5_system_history_1
UNION
SELECT
*
FROM
tp5_system_history_2
UNION
SELECT
*
FROM
tp5_system_history_3
UNION
SELECT
*
FROM
tp5_system_history_4
UNION
SELECT
*
FROM
tp5_system_history_5
) AS SystemHistory
WHERE
`SystemHistory`.`delete_time` IS NULL
ORDER BY
`sh_id`
LIMIT 20 最佳答案