rszl数据表和crjsj数据表的关联查询

'查找姓名为 '某某某' 或者 卡号为99999999 或者 编号为 '号号号' 的crjsj资料 和人事资料
;----------------------------------------------------------------------
SELECT crjsj.id, rszl.bh, crjsj.kh, rszl.xm, crjsj.time8, crjsj.date8, crjsj.mjjbh, crjsj.mjkzqbh, crjsj.syqk, crjsj.crjqk
FROM crjsj RIGHT JOIN rszl ON crjsj.kh = rszl.kh
WHERE
 crjsj.kh=99999999
 or
 crjsj.kh=(select kh from rszl where xm='某某某' and dele=0)
 or
 crjsj.kh=(select kh from rszl where bh='号号号' and dele=0)

  and date8 between #2005-1-26# and #2005-7-26#
;----------------------------------------------------------------------
select a.id,b.bh,a.kh,b.xm,a.date8,a.time8 from crjsj a,rszl b where
       a.kh=b.kh and
       (a.kh=1 or
        a.kh=(select top 1 kh from rszl where xm='某某某' and dele=0) or
        a.kh=(select top 1 kh from rszl where bh='号号号' and dele=0)
        ) and
       a.date8 between #2005-7-26# and #2005-7-26#
;----------------------------------------------------------------------

转载于:https://my.oschina.net/XTechFly/blog/639614

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值