本文介绍了AND或导致出现比应有的结果更多的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试显示与特定时间范围匹配的结果-效果很好.但是,我想添加一个子句,该子句表明显示的结果必须是party_type 12.

I'm trying to display results for that match a specific timeframe - which works fine. However, I wanted to add a clause that would say that the results shown must be either party_type 1 or 2.

所以我做到了

WHERE start_datetime >= '$DATE_START_SELECTED'
AND end_datetime < '$DATE_END_SELECTED' 
AND PARTY_TYPE='1'
OR PARTY_TYPE='2'
GROUP BY events.ENTRANCE_PRICE

但是现在它显示了昨天的其他事件……有趣的是,它没有显示任何进一步的事件.

But now it's showing some additional events from yesterday... What's interesting though, is that it's not showing any events that are further back.

推荐答案

这应该可以解决问题

WHERE start_datetime >= '$DATE_START_SELECTED'
AND end_datetime < '$DATE_END_SELECTED' 
AND (PARTY_TYPE='1'
OR PARTY_TYPE='2')
GROUP BY events.ENTRANCE_PRICE

整个东西的版本会稍微干净一点

Slightly cleaner version of whole thing would be

WHERE start_datetime >= '$DATE_START_SELECTED'
AND end_datetime < '$DATE_END_SELECTED' 
AND (PARTY_TYPE IN (1,2))
GROUP BY events.ENTRANCE_PRICE

您可能还想查看此处,以了解有关使用多重的更多信息条件在哪里.

You might also want to check out here to learn more about using Multiple WHERE conditions.

这篇关于AND或导致出现比应有的结果更多的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 03:19