这个sql语句如何写?

来源:百度知道 编辑:UC知道 时间:2024/05/06 10:35:05
有a、b俩个表,其中都有字段id_no,现将b表中符合itm=1且 field_name=3的数据筛选出来,并将对应的id_no在a表中的字段tile_no全部赋值为3。请问这个sql语句如何写?

update a set tile_no=3 where id_no in (select id_no from b where itm=1 and field_name=3)

sql = "select * from b where itm='1' and field_name='3'"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,1
id_no=rs("id_no")
conn.Execute = "update a set tile_no=3 where id_no="&id_no
rs.movenext
loop
rs.close
set rs=nothing

这个得用子查询:
update a set tile_no=3 where id_no in
(select id_no from b where itm=1 and field_name=3)