求个SQL语句 - MS-SQL Server / 疑难问题
A表:
thread_id msg_box read
1 4 1
2 1 1
3 1 0
4 1 1
B表:
_id read
2 0
3 1
4 1
5 1
6 0
我想取出A表中read为1与B表中read为1的总数
我的SQL语句是这样:
select count(*)+(select count(*) from b where read=1)
from a
where read=1
这样确实可以取出来,但是太笨了。。。有没有什么好的方法吗?
补充一下,两表之间没有主键与外键的关系
这种方法不会笨
-。-是嘛
多谢
相关问答:
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......
请教高手:
以下是数据库中的三条记录,英文为字段名称
id planname TaskBeginTime Status
329 2010年03 ......
求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......
需求如下:
学院 academy(aid,aname)
班级 class(cid,cname,aid)
学生 stu(sid,sname,aid,cid)
住宿区 region(rid,rname)
宿舍楼 build(bid,rid,bnote) bnote是‘男’/‘女’
宿舍 dorm(did,rid,bid,bedn ......