达梦数据库报错select ca count atthumb id as thumb countfrom cms article ca9left join app thumb at on caarticle id = attype id and attype = 2 and atstatus = 1Bwherecadel flag = 0group by caarticle id order by
在该SQL语句中,存在以下几个问题:
-
"thumb id" 应该改为 "thumb_id"。
-
"B" 是一个无效的字符,应该删除。
-
在 group by 子句中,需要将列的名称改为别名 "ca.article_id",否则会报错。
修改后的SQL语句如下:
select ca.*, count(at.thumb_id) as thumb_count from cms_article ca left join app_thumb at on ca.article_id = at.type_id and at.type = 2 and at.status = 1 where ca.del_flag = 0 group by ca.article_id order by ca.create_date desc
原文地址: https://www.cveoy.top/t/topic/eCOm 著作权归作者所有。请勿转载和采集!