不支持引用'seg_type'(对组函数的引用)

时间:2016-10-22 07:28:20

标签: mysql

我写了一个sql,它告诉我这个例外,我怎么能解决这个问题

SELECT 
b.project_id,
GROUP_CONCAT(b.segment_type ORDER BY b.segment_type SEPARATOR ',' )  AS seg_type
FROM t_project_bid_announce_draft b  
LEFT JOIN t_project_segment t ON t.project_id = b.project_id
WHERE (b.review_status = 2 OR  b.review_status = 3)
AND b.deleted = 0
AND seg_type != t.segment_type
GROUP BY b.project_id

请帮助我,非常感谢。

更新

我使用不带

的sql
AND seg_type != t.segment_type

SELECT b.project_id,GROUP_CONCAT(b.segment_type ORDER BY b.segment_type SEPARATOR ',' )  
AS seg_type,t.segment_type 
FROM t_project_bid_announce_draft b  
LEFT JOIN t_project_segment t ON t.project_id = b.project_id
WHERE (b.review_status = 2 OR  b.review_status = 3)
AND b.deleted = 0
GROUP BY b.project_id

而且我得到了这个RESULT

我想比较

seg_type

t.segment_type

0 个答案:

没有答案