我试图在postgresql中运行以下查询:
select * from movies where release_date = current_date;
它响应以下错误:
ERROR: operator does not exist: character varying = date
LINE 1: select * from movies where release_date = current_date;
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
似乎我需要将current_date函数返回的日期转换为字符串,以便比较起作用。我该怎么做?
答案 0 :(得分:0)
答案 1 :(得分:0)
假设您的release_date
列可以投放到某个日期,那么您最好选择:
select * from movies where cast(release_date as date) = current_date;
CAST
功能是SQL-92 standard的一部分,可以让您的查询在多个平台上移植。