[英]MySQL SELECT all except where two columns have specific data together
抱歉,标题如此混乱,下面是我的表格(示例)以及我要实现的目标。
uid | title | comment | duration | timestamp
---------------------------------------------------------
1 | test | test | d | 2013-09-15 12:00:00
2 | test | test | w | 2013-09-15 12:00:00
3 | test | test | m | 2013-09-30 12:00:00
4 | test | test | y | 2013-12-31 12:00:00
5 | test | test | d | 2013-09-16 12:00:00
基本上,我需要从该表中选择SELECT *的查询,除非duration = d
AND timestamp = 2013-09-15 12:00:00
在一起。 因此,应该从结果中排除的唯一记录是第1行。
我需要的东西似乎是如此简单,我确定自己会丢失一些东西,但是我在这方面遇到了困难。
所有帮助极大的赞赏。
select *
from table
where not (duration = 'd' AND timestamp = '2013-09-15 12:00:00');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.