我想从表2中找到值。在表2上,它有多个连接条件。它总是得到表2中的所有条件。表1有重复记录,我不希望是
t1
<表类>id trx_id tbody><<tr>1 trx1234 2trx5678 3 trx4321 4trx8765 表类>
你说表1有重复的记录,但表2有。根据你的表结构。
这对你很有帮助
SELECT distinct a.id, a.trx_id, b.status
FROM
dbo.t1 a
LEFT JOIN
dbo.t2 b on a.trx_id = b.trx_id
WHERE b.status = 'success';
结果将显示
id | trx_id | status
1 |trx1234 | success