SQL 根据表A的数据修改表B,当一条表B的数据匹配到多条表A的数据时选其中一条修改

 update B
set _flg = 'update',
b_string1 = t4.a_string1,
b_string2 = t4.a_string2,
b_string3 = t4.a_string3,
b_string4 = t4.a_string4,
b_string5 = t4.a_string5,
update_by = current_user,
update_date = getdate()
from B t3
inner join A t4 
on t3.id = t4.id and t3.no = t4.no
where exists
(
    select 1 from A t5 where t5.id + ',' +t5.no = t3.id + ',' + t3.no
    and (
            t3.b_string1 <> t5.a_string1
            or t3.b_string2 <> t5.a_string2
            or t3.b_string3 <> t5.a_string3
            or t3.b_string4 <> t5.a_string4
            or t3.b_string5 <> t5.a_string5
        )
)

当id 和 no 相同的情况下,A数据出现两条或者多条,怎么选择其中的一条来修改,代码应该怎么写? 求大神指点

通过id和no组合分组,ROW_NUMBER()over (partition by id+','+no ) rn先对A表进行行编号,条件多加一个 rn=1

 update B
set _flg = 'update',
b_string1 = t4.a_string1,
b_string2 = t4.a_string2,
b_string3 = t4.a_string3,
b_string4 = t4.a_string4,
b_string5 = t4.a_string5,
update_by = current_user,
update_date = getdate()
from B t3
inner join (select a.*,ROW_NUMBER()over (partition by id+','+no ) rn from a)  t4 
on t3.id = t4.id and t3.no = t4.no
where exists
(
    select 1 from A t5 where t5.id + ',' +t5.no = t3.id + ',' + t3.no
    and (
            t3.b_string1 <> t5.a_string1
            or t3.b_string2 <> t5.a_string2
            or t3.b_string3 <> t5.a_string3
            or t3.b_string4 <> t5.a_string4
            or t3.b_string5 <> t5.a_string5
        )
) and t4.rn=1
没有建表语句和数据,SQL没有调测,只是这么一个意思。

mysql 数据库select 1 from A t5 where t5.id + ',' +t5.no = t3.id + ',' + t3.no 最后加limit 0,1
oracle数据库 select * from A t5 where t5.id + ',' +t5.no = t3.id + ',' + t3.no 把这怎么查询A表的语句当成子查询 select * from (子查询) WHERE ROWNUM<=1
sqlserver数据库 select top 10 * from A t5 where t5.id + ',' +t5.no = t3.id + ',' + t3.no