在我的查询中,我想用And和OR来写where逻辑。但我的查询不起作用。
select *
from `data`
where `city`='mycity'
AND performDate='4'
and (curtime() >= `valid_from` OR curtime() <= `valid_to`)
and perform_type='ptype'
我认为
(curtime() >=
`valid_from` OR curtime() <= `valid_to`)
此逻辑不起作用
未测试---
$time = curtime();
SELECT * FROM data WHERE city = 'mycity' AND performDate = '4' AND perform_type = 'ptype' AND ($time >= 'valid_from' OR $time <= 'valid to');
来源:http://www.techonthenet.com/mysql/and_or.php
将每个OR更改为AND
select *
from `data`
where `city`='mycity'
AND performDate='4'
and (curtime() >= `valid_from` AND curtime() <= `valid_to`)
and perform_type='ptype'