inner JOIN mysql query issue
Have 2 tables TABLE1 and TABLE2
Have to fetch record from both table in below given 2 criteria with INNER JOIN.
[1] Fetch record from when TABLE1.id = TABLE2.id
[2] Fetch record from when TABLE1.id NOT IN TABLE2.id field
CAN any one开发者_JAVA百科 tell query for both criteria.
Edit:
table1
id
1
2
3
table2
id
1
2
result for criteria 1
1, 2
result for criteria 2
3
1)
SELECT * FROM [Table1]
INNER JOIN [Table2] On [Table1].[ID]=[Table2].[ID]
2)
SELECT * FROM [table1]
LEFT JOIN [Table2] ON [Table1].[ID]=[Table2].[ID]
WHERE [Table2].[ID] IS NULL
EDIT: Tested option 2 and it works as expected
精彩评论