

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why does the update command in MySQL insist on using slanted single quotes?
Use single quotes on string input value. If there is an identifier like table name or column name, then do not use single quotes (use backticks).
Let us first create a table −
mysql> create table DemoTable1552 -> ( -> `key` int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.82 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1552 values(101,'Chris'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1552 values(102,'David'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable1552 values(103,'Mike'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1552;
This will produce the following output −
+------+-------+ | key | Name | +------+-------+ | 101 | Chris | | 102 | David | | 103 | Mike | +------+-------+ 3 rows in set (0.00 sec)
Here is how to use single quotes −
mysql> update DemoTable1552 set `key`=100 where Name='Chris'; Query OK, 1 row affected (0.20 sec) Rows matched: 1 Changed: 1 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1552;
This will produce the following output −
+------+-------+ | key | Name | +------+-------+ | 100 | Chris | | 102 | David | | 103 | Mike | +------+-------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- Update MySQL table on INSERT command with triggers?
- Using MySQL keywords in a query surrounded with single quotes?
- How to escape single quotes in MySQL?
- Using Options on the Command Line for MySQL programs?
- Single quotes vs. double quotes in C or C++
- Single and Double Quotes in Perl
- How can we update columns values on multiple rows with a single MySQL UPDATE statement?
- Using single quotes around database and table name isn’t working in MySQL?
- How to update multiple rows using single WHERE clause in MySQL?
- Does MySQL update with regexp possible?
- What do single quotes do in C++ when used on multiple characters?
- How to insert date in single quotes with MySQL date formats?
- Print newline in PHP in single quotes
- Update only a single column value in MySQL
- MySQL update multiple records in a single query?
Advertisements