2015-03-03 66 views
0

在Postgres中这样做的正确方法是什么?在Postgres中执行IN(日期范围)的正确方法是什么?

delete from days where date IN ("2014-02-15", "2014-02-07", 
           "2014-02-08", "2014-02-09", "2014-03-01"); 


ERROR -- : PG::UndefinedColumn: ERROR: column "2014-02-15" does not exist 

在MySQL和SQLITE3工作正常

+0

什么数据类型是'date'? – Bohemian 2015-03-03 06:19:17

+0

该列的类型和名称是'date' – Tilo 2015-03-03 06:20:46

+1

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS – 2015-03-03 06:39:00

回答

3

IN的说法应该是正确的,但你做的和PostgreSQL抱怨不使用"字符串。 "用于表,列和其他对象,而字符串由'引用。

但是,您也可以使用between条款等

WHERE date between <first_date> and <last_date> 
+0

甜!谢谢!从来没有在MySQL中遇到过这个问题 – Tilo 2015-03-03 06:24:23

+1

MySQL在这里并没有关注SQL标准,这在很多这些错误中很糟糕。 – frlan 2015-03-03 06:25:31

+0

不能使用简单的日期与'where'比较..不幸的是我需要特定的手工挑选日期 – Tilo 2015-03-03 06:27:22

相关问题