请教SQL2000多条件查询语句

来源:百度知道 编辑:UC知道 时间:2024/06/27 14:27:16
例:
在A表中,姓名为李四,代号为001

在B表中,没有姓名,只有代号,结果=0 性别=男

我要将结果改为1,查询条件为A表中的姓名=李四,及B表中特征为男,怎么做这个语句?我只做到了这一步,还有B表的查询条件怎么连接上?

update B表 set 结果='1' where 代号 in (select 代号 from A表 where 姓名 = '李四')

update b
set 结果=1
from a inner join b on a.代号=b.代号
where a.姓名= '李四' and b.性别='男'

你的两个表的主键应该就是各自表中的代号。我写的sql中的a,b就代表a,b表。
或者用你们老师教的形式,跟上面一个意思:
update b
set 结果=1
from a,b
where a.代号=b.代号
and a.姓名= '李四' and b.性别='男'

update B表 set 结果='1' where 代号 in (select 代号 from A表 where 姓名 = '李四') and 性别='男'