SELECT *
FROM vtiger_crmentity
where createdtime BETWEEN '2019-06-11 14:07:47' AND '2019-06-11 14:08:47'
OR modifiedtime BETWEEN '2019-06-11 14:07:47' AND '2019-06-11 14:08:47'
AND smownerid = '1'
AND setype = 'Potentials'
AND deleted = '0'`
但是请不要给我正确的答案, 建议改进。 来自数据库的查询响应。 https://prnt.sc/o0hhq9
答案 0 :(得分:3)
OR
条件需要括号。
SELECT *
FROM vtiger_crmentity
where (createdtime BETWEEN '2019-06-11 14:07:47' AND '2019-06-11 14:08:47'
OR modifiedtime BETWEEN '2019-06-11 14:07:47' AND '2019-06-11 14:08:47')
AND smownerid = '1'
AND setype = 'Potentials'
AND deleted = '0'`
答案 1 :(得分:0)
尝试使用括号()
来分隔OR逻辑;更新后的代码看起来像
SELECT *
FROM vtiger_crmentity
WHERE
(
createdtime BETWEEN '2019-06-11 14:07:47' AND '2019-06-11 14:08:47'
OR
modifiedtime BETWEEN '2019-06-11 14:07:47' AND '2019-06-11 14:08:47'
)
AND smownerid = '1'
AND setype = 'Potentials'
AND deleted = '0'
;