0

I want to run below command in my SQL database to delete links of a particular user between a particular date range:

DELETE FROM `links`
WHERE `user_id` = 83238 AND
      `created` BETWEEN `2018-12-07 00:00:00` AND `2018-12-08 23:59:59`;

But it doesn't works.

Shadow
  • 33,525
  • 10
  • 51
  • 64
AnonHaxer
  • 1
  • 1
  • "It doesn't work" -- Do you mean there's an error? What's the error? – The Impaler Jan 09 '19 at 18:25
  • It says - #1054 - Unknown column '2018-12-07 00:00:00' in 'where clause' – AnonHaxer Jan 09 '19 at 18:29
  • 3
    Don't use backticks to enclose text or datetime values, use quotes `'` – forpas Jan 09 '19 at 18:30
  • like @forpas said but better is to drop using the backticks all the way to made your query ANSI SQL valid meaning you can port it between database vendors when needed. – Raymond Nijland Jan 09 '19 at 18:41
  • @RaymondNijland it seems that the OP did not use even backticks. These were added by Shadow while editing. – forpas Jan 09 '19 at 18:44
  • yes i now notice i didn't check normally nobody edites topicstarters code like that to answer the question @forpas not sure Shadow did this..Because no MySQL keywords and reserved words are used in the column or table names.. – Raymond Nijland Jan 09 '19 at 18:50

0 Answers0