[英]MySQL SELECT all except where two columns have specific data together
Sorry the title is so confusing, below is my table (example) and what I am trying to achieve. 抱歉,标题如此混乱,下面是我的表格(示例)以及我要实现的目标。
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
Basically I need a query that SELECT * from this table except when duration = d
AND timestamp = 2013-09-15 12:00:00
together. 基本上,我需要从该表中选择SELECT *的查询,除非
duration = d
AND timestamp = 2013-09-15 12:00:00
在一起。 So the only record that should be excluded from the results is row 1. 因此,应该从结果中排除的唯一记录是第1行。
What I need seems so simple and I am sure I am missing something, but I am having a real hard time with it... 我需要的东西似乎是如此简单,我确定自己会丢失一些东西,但是我在这方面遇到了困难。
All help greatly appreciated. 所有帮助极大的赞赏。
select *
from table
where not (duration = 'd' AND timestamp = '2013-09-15 12:00:00');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.