正常sqlSELECT CASE WHEN da2.area_id IS NULL THEN 0 ELSE da1.area_id END AS country, CASE da3.area_id IS NULL WHEN 1 THEN CASE da2.area_id IS NULL WHEN 1 THEN 0 ELSE da1.area_id END ELSE da2.area_id END AS city, IFNULL(da3.area_id, IFNULL(da2.area_id, da1.area_id)) AS province INTO @country, @city, @province FROM dbn_area da1 LEFT JOIN dbn_area da2 ON da1.parent_id = da2.area_id LEFT JOIN dbn_area da3 ON da2.parent_id = da3.area_id WHERE da1.area_id = 5342;
解析为SELECT CASE WHEN da2.area_id IS NULL THEN 0 ELSE da1.area_id END AS country , CASE da3.area_id IS NULL WHEN 1 THEN CASE da2.area_id IS NULL WHEN 1 THEN 0 ELSE da1.area_id END ELSE da2.area_id END AS city , IFNULL(da3.area_id, IFNULL(da2.area_id, da1.area_id)) AS province INTO (@country, @city, @province) FROM dbn_area da1 LEFT JOIN dbn_area da2 ON da1.parent_id = da2.area_id LEFT JOIN dbn_area da3 ON da2.parent_id = da3.area_id WHERE da1.area_id = 5342;
into子句加了对括号,执行报错
1条答案
按热度按时间s8vozzvw1#
代码在这里
https://github.com/alibaba/druid/blob/master/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java#L3254