select * from kczxxb a where ((a.Jybz = -1) or (a.Jybz= -2))
and ( a.Npkh In (select b.Npkh from huikb b) )
and ( a.Npkh In (select b.Npkh from huikb b) )
解决方案 »
- SQLSER2000能跟踪到触发器吗?
- SQL 2000 和 SQL 2005 安装在一起相安无事,SQL 2000 和 SQL 7.0 能享受齐人之福不?
- SQL 面试 郁闷了
- 如何删除复制生成的数据库?
- 让系统无法插入一条重复记录,大家是怎么做的?
- 元组 not int 集合 如: where (1,2) not int (select a,b from my_table)
- sql server下运行DOS命令问题2
- 如何统计连续重复数据的数目
- datetime字段插入值含有英文月份时出错的非sql语句解决?
- Help Me 寻找PB6.0安装盘
- SQL Server 中列的缺省值放在哪个系统表?
- 这样的查询语句如何实现?
select * from kczxxb a inner join huikb b on a.Npkh=b.Npkh and a.Jybz in(-1,-2)
create table huikb( Npkh int, Cs int)
insert into huikb select 123, 1 create table kczxxb(Dh varchar(20), Npkh int, Jybz int)
insert into kczxxb select '00001', 123, -1
insert into kczxxb select '00002', 321, -2kczxxb.Jybz=-1时,如果该记录中的Npkh的值在huikb中有对应的值话,就显示kczxxb.Jybz=-1和kczxxb.Jybz=-2的两条记录,如果Npkh的值在没huikb中没有对应的值,那就不显示,
请问如何写这语句??select * from kczxxb where exists(
select * from kczxxb a
where exists(select * from huikb where a.npkh=npkh) )