SELECT *
FROM [dbo].[t_ttgzb]
WHERE htbm = '595'
SELECT *
FROM [dbo].[t_ttgzb]
WHERE htbm = '283'
我想让查询htbm(合同编码) = '595' 查询出来数据中的hyh(会员号)更新为查询htbm (合同编码)= '283'数据中的hyh(会员号),条件是htbm = '595' 中的xm(姓名)等于htbm = '283'中的xm(姓名),查询语句应该怎么写
FROM [dbo].[t_ttgzb]
WHERE htbm = '595'
SELECT *
FROM [dbo].[t_ttgzb]
WHERE htbm = '283'
我想让查询htbm(合同编码) = '595' 查询出来数据中的hyh(会员号)更新为查询htbm (合同编码)= '283'数据中的hyh(会员号),条件是htbm = '595' 中的xm(姓名)等于htbm = '283'中的xm(姓名),查询语句应该怎么写
update a
set a.hyh=b.hyh
from [dbo].[t_ttgzb] a,[dbo].[t_ttgzb] b
where a.htbm = '595' and b.htbm = '283'
and a.xm=b.xm
a,[dbo].[t_ttgzb] b where a.htbm = '595' and b.htbm = '283' and a.xm = b.xm
FROM [dbo].[t_ttgzb] as a inner join [dbo].[t_ttgzb] as b on a.xm=b.xm
WHERE a.htbm = '595' and b.htbm='283'