UPDATE data_catalog_dept_group_statistics_temp t, ( SELECT c.cata_group_id AS group_id, count( 1 ) AS cata_amount FROM data_catalog c WHERE is_del = 0 AND cata_group_id LIKE CONCAT('3071140224','%') GROUP BY c.cata_group_id )tmp set t.base_cata_amount = tmp.cata_amount where t.group_id = tmp.group_id; 语法哪里有问题
时间: 2024-03-21 12:38:12 浏览: 66
LED_test.zip_JZNO_LED TEST_The Test_cata8e_presentoqi
这段 SQL 语句的语法是有问题的,问题在于子查询的 SELECT 子句中,GROUP BY 子句最后缺少了一个空格。正确的写法应该是:
```
UPDATE
data_catalog_dept_group_statistics_temp t,
(
SELECT
c.cata_group_id AS group_id,
count(1) AS cata_amount
FROM
data_catalog c
WHERE
is_del = 0 AND
cata_group_id LIKE CONCAT('3071140224', '%')
GROUP BY
c.cata_group_id
) tmp
SET
t.base_cata_amount = tmp.cata_amount
WHERE
t.group_id = tmp.group_id;
```
在子查询中,GROUP BY 子句最后的 AS 子句之后需要加一个空格,否则会被认为是一个新的字段,导致语法错误。
阅读全文