3 Replies - 178 Views - Last Post: 20 November 2017 - 07:05 PM Rate Topic: -----

#1 COKEDUDE  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 268
  • Joined: 01-February 10

sql update record to null

Posted 20 November 2017 - 06:46 PM

I am trying to set a record back to null. I was able to change it from null and now I want to change it back to null. For some reason it is not working.

This worked perfectly fine:

UPDATE  members set end_date = "2017-01-18" where player = 1 and end_date is NULL;
Query OK, 1 row affected (0.07 sec)
Rows matched: 1  Changed: 1  Warnings: 0


This is not working.

UPDATE  members set end_date = NULL where player = 1 and end_date is "2017-01-18";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"2017-01-18"' at line 1


Is This A Good Question/Topic? 0
  • +

Replies To: sql update record to null

#2 astonecipher  Icon User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2363
  • View blog
  • Posts: 9,483
  • Joined: 03-December 12

Re: sql update record to null

Posted 20 November 2017 - 06:50 PM

Read the error message. Your issue has nothing to do with the null value, it has to do with your where clause.
Was This Post Helpful? 0
  • +
  • -

#3 COKEDUDE  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 268
  • Joined: 01-February 10

Re: sql update record to null

Posted 20 November 2017 - 07:05 PM

Thank you. "is" instead of "=".
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher  Icon User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2363
  • View blog
  • Posts: 9,483
  • Joined: 03-December 12

Re: sql update record to null

Posted 20 November 2017 - 07:05 PM

That would be it!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1