MySQL クエリを台無しにしています... 別のテーブルに存在しない値を持つテーブル レコードを取得したいのですが、NOT IN 操作を使用したくありません。次に、LEFT JOIN を使用して一致しないデータを表示しようとしました。ただし、空の結果が表示されます。
tbl_comment
comment_id | comment_message
----------------------------
1_1 | some text1...
1_2 | some text2...
1_3 | some text3...
2_1 | some text4...
2_2 | some text5...
2_3 | some text6...
tbl_analysis
analysis_id | analysis_message_id
----------------------------
1.0.1 | 1_1
1.0.1 | 1_2
1.0.1 | 2_1
1.0.2 | 1_3
1.0.3 | 2_2
私の間違ったクエリ (空の結果):
SELECT comments.* ,
analysis.*
FROM tbl_comment as comments
LEFT JOIN tbl_analysis as analysis
ON comments.comment_id = analysis.analysis_message_id
WHERE analysis.analysis_id != '1.0.1'
推奨される結果: ( analysis_idが1.0.1と等しくない、またはtbl_analysisに存在しないというすべてのコメントを見つけます)
comment_id | comment_message | analysis_id | analysis_message_id
----------------------------------------------------------------
1_3 | some text3... | 1.0.2 | 1_3
2_2 | some text5... | 1.0.3 | 2_2
2_3 | some text6... | NULL | NULL
多大な助けをありがとう...