sql 中( in , or ,and)

其实在大部分情况下 in 和 or 是没有什么区别的

and 表示并列关系 即满足 a 同样满足 b条件

select

  *

from

left join  xxx on 

where 

 a And b

如果在以下这种情况下使用 or 关键字时 应该加上() 在与and 共用

where  (a or b) 

and c 

使用 in关键字就需要 直接 字段名 in ('','') 在加 and

SELECT
			oo.id id,
			oo.org_name,
			oo.org_id,
			oo.det_end_date,
			oo.ord_code,
			oei.id oeiID,
			os.at_qualified,
			os.sam_name AS samName,
			os.sam_code AS samCode,
			os.id samId,
			odr.id AS odRid
		FROM
			xxxxx oo
		LEFT JOIN xxxx oei ON oei.id = oo.enp_id
		LEFT JOIN xxxx os ON oo.id = os.ord_id
		LEFT JOIN xxxx odr ON odr.ord_sam_id = os.id
		WHERE
			(oo.ord_status = '6'
		OR oo.ord_status = '5')
		AND oo.enp_id = 7300785981126488
		ORDER BY
			oo.create_date DESC

  

提供简单参考sql, 

转载于:https://www.cnblogs.com/wshuo/p/5917339.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值