这个SQL怎么写 表 1 id jh flag1 A 02 B 0表2cid cjh flag1 A1 11 A2 1表1的ID 就是表2 的CID 当表2 的cid 的flag都是1时 表1 的第一行 flag 也是1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select A.id,A.jh,case when n=0 then 0 else 1 end as flagfrom(select A.id,A.jh,min(flag) nfrom tb1 A,tb2 Bwhere A.id = B.cidgroup by A.id,A.jh) select id, jh, flag = case when not exists (select 1 from 表2 where cid=t.id and flag <> 1) then 1 else 0 end from 表1 t --写个更新的update tb1set flag=1from tb1 join tb2 on tb1.id=tb2.cidwhere not exists(select * from tb2 where tb1.id=cid and flag<>1) 是表2update时候改表1?用trigger 以下语句可以连接远程电脑上的数据库吗? 今天学会一个新名词“友情帮顶”,太有意思了,哈哈 求一个多表查询的语句:5个表分两组,谢谢 求一个insert,update的触发器 语句中where 1<>1代表什么意思? 查询结果为什么Null值的记录找不出来 请问string类型变量最多可以赋值多少个字符??? 这个SQL语句好难,请高手们帮帮我。高分感谢 SQL求助 关于VFP中的记录复制 超简单问题 求多解决思路 windows 2003企业版上安装sql server2000 企业版,请问sql server2000最多可以使用多达内存。
from
(
select A.id,A.jh,min(flag) n
from tb1 A,tb2 B
where A.id = B.cid
group by A.id,A.jh
)
update tb1
set flag=1
from tb1 join tb2 on tb1.id=tb2.cid
where not exists(select * from tb2 where tb1.id=cid and flag<>1)
用trigger