![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 do backticks won’t work in the SET part of an UPDATE query (for MySQL)?
Backticks would work if written correctly as in the below syntax −
update `yourTableName` set `yourTableName`.`yourColumnName`='yourNewValue' where yourCondition;
Let us first create a −
mysql> create table `DemoTable_1401` -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.52 sec)
Insert some records in the table using insert −
mysql> insert into `DemoTable_1401` values('Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into `DemoTable_1401` values('David'); Query OK, 1 row affected (0.10 sec) mysql> insert into `DemoTable_1401` values('Bob'); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select −
mysql> select * from `DemoTable_1401`;
This will produce the following output −
+-------+ | Name | +-------+ | Chris | | David | | Bob | +-------+ 3 rows in set (0.00 sec)
Here is the query to work with backticks −
mysql> update `DemoTable_1401` set `DemoTable_1401`.`Name`='Adam' where `Name`='David'; Query OK, 1 row affected (0.15 sec) Rows matched: 1 Changed: 1 Warnings: 0
Let us check the table records once again −
mysql> select * from `DemoTable_1401`;
This will produce the following output −
+-------+ | Name | +-------+ | Chris | | Adam | | Bob | +-------+ 3 rows in set (0.00 sec)
Advertisements