sql update set select 怎么结合

如何实现
update BAS_COMPANY set TYPE ='5' where COMNO = (select * from hbposev9..t_bd_supcust_info where supcust_flag ='C')
更新里 含查询
更新BAS_COMPANY表内TYPE列为5
条件是另外 hbposev9..t_bd_sup表里 supcust_flag为C

就是一个子查询与修改结合使用

等于号改成in就可以了..

可以先把需要更新的数据查出来。先用select * from table where table.column='';确定这条数据是你需要修改的。然后在加上update查出来的数据。
update table set table.column='' where table.column in(select table.column from table where table.column='');

updata
BAS_COMPANY a
LEFT JOIN hbposev9..t_bd_sup b ON a.COMNO = b.???(这里的字段自己加一下..我也不知道你写的啥)
SET
a.TYPE ='5'
WHERE
b.supcust_flag ='C'

很简单的联查

补充一下...select的作用是选择并显示...任何语句都可以查询

UPDATE TABLE_NAME
SET column_name1 = VALUE WHRER column_name2 = VALUE

update BAS_COMPANY
set TYPE = '5'
where COMNO in
(select COMNO from hbposev9 .. t_bd_supcust_info where supcust_flag = 'C')

如果 select是个结果集的话 等号需要换成in select * 需要换成具体的列 (应该就是这样了)

将where中的=换成in,然后将seclet后面的* 换成具体的列名即可

这要看你后面的查询的结果有几个,如果就一个用=就可以,但是子查询如果有多个结果,用=就会报错,用in比较好。
in表示你要的东西在子查询查到的结果中

update A inner join(select id,name from B) c on A.id = c.id set A.name = c.name;

select是查询语句中使用的
update set 对象名 (,,...)values (...)更新语句

update table set table.column='' where table.column in(select table.column from table where table.column='');

别使用in查询,影响性能!

 update BAS_COMPANY set TYPE ='5' where exists (select * from hbposev9..t_bd_supcust_info where supcust_flag ='C')

使用内连接即可
update a set a.TYPE ='5' from BAS_COMPANY a
inner join hbposev9..t_bd_supcust_info b on a.COMNO=b.XXX
where b.supcust_flag ='C'