Re: Using SELECT WHERE
От | Tom Lane |
---|---|
Тема | Re: Using SELECT WHERE |
Дата | |
Msg-id | 20848.1082484057@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Using SELECT WHERE (Michal Lijowski <michal@cvu.wustl.edu>) |
Список | pgsql-novice |
Michal Lijowski <michal@cvu.wustl.edu> writes: > I made a database and I would like to select entries > which have data not equal to the specified date. > RabStudies=> SELECT RabNo, ImplantDate, Comments FROM RabStudiesInfo > where implantdate <> 0001-01-01; What you have on the right there is an integer expression with a value of -1 (one minus one minus one). You need to put quotes around it to make it be treated as a date constant: where implantdate <> '0001-01-01'; Just FYI, pretty much any non-numeric literal has to be quoted as if it were a string. Postgres usually infers the specific type from context --- here, since you're comparing to a column of type date, the unspecified-type literal will be presumed to be a date. You can add an explicit cast if you need to force the literal to be converted to a specific datatype. where implantdate <> cast('0001-01-01' as date); where implantdate <> '0001-01-01'::date; The CAST syntax is SQL-standard, the :: syntax is a Postgres-ism. regards, tom lane
В списке pgsql-novice по дате отправления: