
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
Select Column Name with Spaces in MySQL
To select a column name with spaces, use the back tick symbol with column name. The symbol is ( ` `). Back tick is displayed in the keyboard below the tilde operator ( ~).
Firstly, create a table −
mysql> CREATE table SpaceColumn -> ( -> `Student Name` varchar(100) -> ); Query OK, 0 rows affected (0.48 sec)
Inserting records
mysql> INSERT into SpaceColumn values('John'); Query OK, 1 row affected (0.18 sec) mysql> INSERT into SpaceColumn values('Bob'); Query OK, 1 row affected (0.17 sec)
The syntax to get column name with space is as follows −
SELECT `column_name` from yourTableName;
Now I will apply the above syntax to get the result for my column. The query is as follows −
mysql> SELECT `Student Name` from SpaceColumn;
The following is the output −
+--------------+ | Student Name | +--------------+ | John | | Bob | +--------------+ 2 rows in set (0.00 sec)
Advertisements