

- 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
Using single quotes around database and table name isn’t working in MySQL?
You need to use backticks around table name as well as database name. The syntax is as follows:
UPDATE `yourDatabaseName`.`yourTableName` SET yourColumnName1=yourColumnName1+1 WHERE yourColumnName2=’yourValue’;
To understand the above syntax, let us create a table. The query to create a table is as follows:
mysql> use test; Database changed mysql> create table Add1Demo -> ( -> Id varchar(10), -> Value int -> ); Query OK, 0 rows affected (1.19 sec)
Insert some records in the table using insert command. The query is as follows:
mysql> insert into Add1Demo values('1',780); Query OK, 1 row affected (0.17 sec) mysql> insert into Add1Demo values('2',1001); Query OK, 1 row affected (0.18 sec) mysql> insert into Add1Demo values('3',1654); Query OK, 1 row affected (0.15 sec) mysql> insert into Add1Demo values('4',3999); Query OK, 1 row affected (0.09 sec) mysql> insert into Add1Demo values('5',5999); Query OK, 1 row affected (0.10 sec) mysql> insert into Add1Demo values('6',799); Query OK, 1 row affected (0.08 sec) mysql> insert into Add1Demo values('8',899); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from Add1Demo;
The following is the output:
+------+-------+ | Id | Value | +------+-------+ | 1 | 780 | | 2 | 1001 | | 3 | 1654 | | 4 | 3999 | | 5 | 5999 | | 6 | 799 | | 8 | 899 | +------+-------+ 7 rows in set (0.00 sec)
Here is the query to use backticks around database name and table name. Do not use single quotes for database and table name. The query is as follows, let’s say to add 1 to current field.
mysql> update `test`.`Add1Demo` -> set Value=Value+1 -> where Id='6'; Query OK, 1 row affected (0.17 sec) Rows matched: 1 Changed: 1 Warnings: 0
Now you can check the table record once again with specific id 6. The query is as follows:
mysql> select *from Add1Demo where Id='6';
The following is the output:
+------+-------+ | Id | Value | +------+-------+ | 6 | 800 | +------+-------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- Sorting a VARCHAR column as FLOAT using the CAST operator isn’t working in MySQL ?
- MySQL isn’t displaying right single quotation mark(’) after insertion of records
- Are quotes around tables and columns in a MySQL query really necessary?
- MySQL throws an error when the table name “match” is not surrounded by single quotes?
- Using MySQL keywords in a query surrounded with single quotes?
- Single and Double Quotes in Perl
- How to escape single quotes in MySQL?
- Single quotes vs. double quotes in C or C++
- Why does the update command in MySQL insist on using slanted single quotes?
- Display MySQL Database, Table, and Column Information
- How to take backup of a single table in a MySQL database?
- MySQL isn’t inserting binary data properly? Which datatype should be used?
- How to insert date in single quotes with MySQL date formats?
- Print newline in PHP in single quotes
- Are MySQL database and table names case-sensitive?
Advertisements