
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Set Blank spaces in column names with MySQL?
To set blank spaces in column names with MySQL, you can use the concept of backticks. Let us first create a table. Following is the query −
mysql> create table blankSpacesDemo -> ( -> `Student Id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> `Student Full Name` varchar(100) -> ); Query OK, 0 rows affected (0.51 sec)
Following is the query to insert some records in the table using insert command −
mysql> insert into blankSpacesDemo(`Student Full Name`) values('John Smith'); Query OK, 1 row affected (0.16 sec) mysql> insert into blankSpacesDemo(`Student Full Name`) values('Carol Taylor'); Query OK, 1 row affected (0.14 sec) mysql> insert into blankSpacesDemo(`Student Full Name`) values('David Miller'); Query OK, 1 row affected (0.15 sec)
Following is the query to display all records from the table using a select statement −
mysql> select `Student Id`,`Student Full Name` from blankSpacesDemo;
Following is the output displaying blank space in column name “Student Full Name” −
+------------+--------------------+ | Student Id | Student Full Name | +------------+--------------------+ | 1 | John Smith | | 2 | Carol Taylor | | 3 | David Miller | +------------+--------------------+ 3 rows in set (0.00 sec)
- Related Articles
- MySQL UPDATE column names and set None values with N/A?
- Lower case column names with MySQL SELECT?
- How to select a column name with spaces in MySQL?
- How to use special characters in column names with MySQL?
- Set 'alias' for all the column names in a single MySQL query
- MySQL update column to NULL for blank values
- Make all column names lower case in MySQL with a single query
- Select column names containing a string in MySQL?
- How can I check the character set of all the tables along with column names in a particular MySQL database?
- Display month names and year from a column with date records with MySQL
- How to strip all spaces from a column in MySQL?
- Setting column values as column names in the MySQL query result?
- Get table column names in alphabetical order in MySQL?
- How to select data from a table where the table name has blank spaces in MYSQL?
- Increment column value ‘ADD’ with MySQL SET clause

Advertisements