1

I am attempting to perform a fairly simple command:

DELETE from table WHERE date = date(’2018-07-01’);

However, when I run this command on MySQL, I receive the following error:

ERROR 1054 (42S22): Unknown column ’2018 in 'where clause'

Any ideas on what I should be doing here so the query can run? I am using MySQL 5.6.35.

Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80
Tom Jackson
  • 515
  • 2
  • 6
  • 9
  • 1
    Probably you have copied the SQL statement from somewhere the qoute looks to be the wrong one.. SQL qoute it should be single qoute like `'`.. Also `date = date(’2018-07-01’)` can be written more simple like `date = '2018-07-01'` – Raymond Nijland Jul 07 '18 at 14:33
  • @RaymondNijland thanks for reply. I corrected the original error message I was seeing. Even if I take out the date() section, I still get the same error: mysql> DELETE from table -> WHERE date = ’2018-07-01’ -> ; ERROR 1054 (42S22): Unknown column '’2018' in 'where clause' – Tom Jackson Jul 07 '18 at 14:38
  • Typo error. voting to close as off-topic. – Roshana Pitigala Jul 07 '18 at 14:47

1 Answers1

4

Strings in SQL are denoted by 's. Your code uses s instead. Additionally, if those are your real table and column names, you should escape them:

DELETE FROM `table` WHERE `date` = DATE('2018-07-01')
Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • 1
    `date = DATE('2018-07-01')` can be written more simple `date = '2018-07-01'` @TomJackson like i said in the comments.. (rememeber the backtick escapes ( ` ) stackoverflow format also works with backticks) – Raymond Nijland Jul 07 '18 at 14:52
  • I have faced this issue due to a trigger. When I deleted the Trigger the issue was solved. Can anyone tell me why so happened? – Harshit Chaurasia Oct 12 '20 at 15:12