我有两张桌子:
表A:
Firstname | LastName | name | AC No | code
-------------|-------------|--------|--------|-----
SH | RA | | 199 | 005
SH | RA | | 199 | 005
SH | RA | | 199 | 005
- 这给出了记录数3
select count(*)
from tableA as y where y.[name] = '' and y.[ac no] = 0000199 and y.code = 005;
表B:
| name | AC No | code
-----------|----------------
| | 199 | 005
| | 199 | 005
| | 199 | 005
- 这给出了记录数3
select count(*)
from tableB where y.[name] = '' and y.[ac no] = 199 and y.code = 005
- 当我加入下面的查询时,给了我9条记录。我认为只有3个记录
select count(*)
from tableA as x right join tableB as y
on x.[ac no] = y.[ac no] and x.code = y.code
where y.[name] = '' and y.[ac no] = 199 and y.code = 005
我基本上需要连接TableA中的“firstname”和“last name”,并在TableB中的“name”中更新
- 我做错了什么?如何解决这个问题,以便我只能获得3条记录?