Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
フィールドid、status、other_fieldsを持つMySQLテーブルがあります
異なる other_fields を持つため、同じ ID とステータスを持つ複数の行があっても問題ありません。
ただし、一部の ID にエラーを示す複数の (異なる) ステータス値がある場合。
エラーを示す ID とステータスのペアを返すクエリを作成するにはどうすればよいですか? 関連する質問への回答を見ましたが、残念ながら、私のケースにジャンプすることはできません.
次のようなものを試してください:
select t1.id, t1.status, t2.status from table t1 inner join table t2 on t1.id = t2.id and t1.status != t2.status order by t1.id
group_concat(t2.status)また、group by t1.id1行のPR IDを取得することもできます..
group_concat(t2.status)
group by t1.id