PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 24, 2022

[FIXED] How do I update a column named Date in SQL?

 October 24, 2022     exasol, sql, sql-update     No comments   

Issue

I have a table that has a column named Date. This causes problems because Date is a data type name. I tried the following statements to escape it:

Update Tables.Subtable SET `Date` = "2022-03-14 07:20:32"  WHERE ID=960646;
Update Tables.Subtable SET "Date" = "2022-03-14 07:20:32"  WHERE ID=960646;

Update Tables.Subtable SET Tables.Subtable."Date" = "2022-03-14 07:20:32"  WHERE ID=960646;
Update Tables.Subtable SET Tables.Subtable.`Date` = "2022-03-14 07:20:32"  WHERE ID=960646;

Update Tables.Subtable SET Subtable."Date" = "2022-03-14 07:20:32"  WHERE ID=960646;
Update Tables.Subtable SET Subtable.`Date` = "2022-03-14 07:20:32"  WHERE ID=960646;

All of them caused an error. What is the right syntax here?


Solution

The problem is in your date literal being delimited by double quotes. This should work:

Update Tables.Subtable SET "Date" = '2022-03-14 07:20:32'  WHERE ID=960646;


Answered By - Zakaria
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing