MySQL不等于 - 不起作用

时间:2013-07-02 18:50:57

标签: mysql phpmyadmin

我试图在PhpMtAdmin 5.6.12,MySQL客户端版本:5.6.12中使用不等于select,但它似乎不起作用:

我试过这个问题:

SELECT * FROM table WHERE field <> 05.05.2013

SELECT * FROM table WHERE field <> '05.05.2013'

SELECT * FROM table WHERE field <> "05.05.2013"

SELECT * FROM table WHERE field != 05.05.2013

SELECT * FROM table WHERE field != '05.05.2013'

SELECT * FROM table WHERE field != "05.05.2013"

SELECT * FROM table WHERE field not in ('05.05.2013')

...

我收到错误消息:

ERROR: Unclosed quote @ 38

STR: '

SQL: SELECT * FROM `table` WHERE field <> \'05.05.2013\'

2 个答案:

答案 0 :(得分:3)

如果字段是日期列,请尝试以下操作:

SELECT * FROM `table` WHERE field != '2013-05-05'

或者这个:

SELECT * FROM `table` WHERE field != STR_TO_DATE("05.05.2013", "%d.%m.%Y")

(假设您的日期格式为day.month.year)。

答案 1 :(得分:0)

问题出在PhpMyAdmin 5.6.12上。 “不等于”在其他环境中完美无缺。