GROUP_CONCAT()中相同数据的相同输出

时间:2016-10-21 10:47:10

标签: mysql

我在一个SQL查询中需要两个子查询 其中一个结果可能是' 1,3,2'另一个是' 1,2,3' 我怎么能判断这两个结果是平等的 我真的需要他们是平等的......

两个子查询是sql

    SELECT t.project_id,GROUP_CONCAT(t.type,',') AS seg_type FROM 
t_project_bid_announce_draft t WHERE t.project_id = '6639124947eb4e0cafc054b9ddcf9f54'

和sql

    SELECT p.segment_type FROM t_project_segment p  WHERE p.project_id = 
'6639124947eb4e0cafc054b9ddcf9f54'

1 个答案:

答案 0 :(得分:0)

使用order by

SELECT t.project_id,
       GROUP_CONCAT(t.type ORDER BY t.type SEPARATOR ',' ) AS seg_type
FROM t_project_bid_announce_draft t
WHERE t.project_id = '6639124947eb4e0cafc054b9ddcf9f54'