SELECT COUNT( * ) FROM ( SELECT t.* FROM ( SELECT p.* FROM package_channel_price_plan p a WHERE a.sys_default = 0 UNION SELECT c.* FROM package_commodity_main_info b LEFT JOIN package_channel_price_plan c ON b.plan_code = c.plan_code WHERE 1 = 1 AND b.commodity_code = '3323070713301825957052' ) AS t WHERE 1 = 1 AND t.plan_status = '1' ORDER BY t.updated_time DESC ) TOTAL 这个sql错在哪里
时间: 2024-04-20 20:22:22 浏览: 114
这个 SQL 语句中的错误在于使用了不正确的表别名和列名。以下是修正后的 SQL 语句:
SELECT COUNT(*) FROM (
SELECT t.* FROM (
SELECT p.* FROM package_channel_price_plan p
WHERE p.sys_default = 0
UNION
SELECT c.* FROM package_commodity_main_info b
LEFT JOIN package_channel_price_plan c ON b.plan_code = c.plan_code
WHERE 1 = 1 AND b.commodity_code = '3323070713301825957052'
) AS t
WHERE 1 = 1 AND t.plan_status = '1'
ORDER BY t.updated_time DESC
) AS TOTAL
阅读全文