SELECT modi, aid FROM (SELECT
GROUP_CONCAT(id) his,
an_id aid,
GROUP_CONCAT(m_id) modi
FROM
ah
GROUP BY an_id, m_id) t1
GROUP BY aid, modi
order by aid;
现在我需要一个mysql
query which will give me a result set where if column
aidhas the same value in two rows should create a new column with same
aidand
modi`。例如,图像中的前两行相同但不同。我需要的结果应该有3列,行应该是,
aid modi modi2
27 6,6,6,6,6,6,6,6,6 8
我对sql很陌生。提前谢谢
最佳答案
一种方法是:
SELECT aid, min(modi) as modi1, max(modi) as modi2
FROM (SELECT an_id as aid,
GROUP_CONCAT(m_id) as modi
FROM annotation_history ah
GROUP BY an_id
) t1
GROUP BY aid
HAVING min(modi) <> max(modi);