求个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
这样确实可以取出来,但是太笨了。。。有没有什么好的方法吗?
补充一下,两表之间没有主键与外键的关系
这种方法不会笨
-。-是嘛
多谢
相关问答:
字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......
求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......
我觉得mysql和sqlserver有共同的地方:
有个问题是关于表的锁问题:
进程A 进程B
select * from user where id in lock share mode(共享锁)
&nb ......
查询学生平均成绩及其名次
SELECT 1+(SELECT COUNT( distinct 平均成绩)
from (SELECT S#,AVG(score) AS 平均成绩
from SC&n ......