
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 Backticks in Contact Gives an Error in MySQL
Do not use backticks, you can use single quotes in CONCAT(). Following is the syntax −
select concat(yourColumnName1,' ',yourColumnName2) from yourTableName;
Let us first create a table −
mysql> create table DemoTable1359 -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.58 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1359 values(101,'Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1359 values(102,'Adam'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1359 values(103,'Mike'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1359 values(104,'John'); Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1359;
This will produce the following output −
+------+-------+ | Id | Name | +------+-------+ | 101 | Chris | | 102 | Adam | | 103 | Mike | | 104 | John | +------+-------+ 4 rows in set (0.00 sec)
Here is the query to use single qotes in CONTACT() −
mysql> select concat(Id,' ',Name) from DemoTable1359;
This will produce the following output −
+---------------------+ | concat(Id,' ',Name) | +---------------------+ | 101 Chris | | 102 Adam | | 103 Mike | | 104 John | +---------------------+ 4 rows in set (0.00 sec)
Advertisements