易截截图软件、单文件、免安装、纯绿色、仅160KB

求sql语句 - MS-SQL Server / 基础类

两个表 B 表的fd_person_id 与A表中的fd_id关联如下
A表
fd_id name  
1 a
2 b
3 c
B表
fd_id fd_person_id  
1 1
2 2

现在要判断 给定一个 A表的 NAME 判断这个name 是否存在与A表中又不存在于B表中
比如 给name 为c 返回的count 为1 给a b d e 等都返回0
谢谢
SQL code:
select * from a where not exists (select 1 from b where a.fd_id=b.fd_id)

and a.name='c'


SQL code:
select count(1) as cnt from b where exists(select 1 from a where a.fd_id= b.fd_person_id and name='c')


SQL code:
select name,num=count(*)
from A left join B on A.fd_id=B.fd_person_id
where B.fd_id is null and name='c'
group by name



ths



相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

求一sql语句 - MS-SQL Server / 疑难问题

现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......

sqlserver错误 - MS-SQL Server / 疑难问题

sqlserver2005 建立的数据库,与手持pda传输数据,最近突然出现无法传递数据的问题,pda端提示的错误时outofmemoryexception,但是pda上面的容量没有问题,
sqlserver的日子上的错误如下:
日期 2010-1-25 14:45: ......

MS SQL作业问题 - MS-SQL Server / 应用实例

如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP

参考:http://hi.baidu.com/toiota ......

请教SQLSERVER的两个问题 - MS-SQL Server / 疑难问题

1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号