简体   繁体   中英

Display all employees where employees hired before 21-NOV-1989 (1989-11-21) in MySQL

My Database has a table named "employee" and "hire_date" column in it. I tried to fire following Query, but got empty set:

mysql> SELECT * from employees
    -> WHERE hire_date < 1989-11-21;

       Empty set, 1 warning (0.00 sec)

Though I have records with hire_date before 21 NOV 1989. Can anyone help me out?

Date literals in MySQL typically require single quotes, so use:

SELECT *
FROM employees
WHERE hire_date < '1989-11-21';

Note that this assumes that your hire_date column be actually date or datetime, or, if text, that you are storing your text dates in YYYY-MM-DD format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM