mysql查询和OR不起作用

时间:2015-07-02 07:19:28

标签: php mysql

在我的查询中,我想用OR编写带有And操作的逻辑。但我的查询不起作用。

(ax bx + ay by) / (ax by - ay bx)

我认为

select * 
from `data` 
where `city`='mycity' 
AND performDate='4' 
and (curtime() >= `valid_from` OR curtime() <= `valid_to`) 
and perform_type='ptype'

这种逻辑不起作用

2 个答案:

答案 0 :(得分:0)

UNTESTED ---

$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

答案 1 :(得分:0)

将每个 OR 更改为 AND

select * 
from `data` 
where `city`='mycity' 
AND performDate='4' 
and (curtime() >= `valid_from` AND curtime() <= `valid_to`) 
and perform_type='ptype'