Home > Database > Mysql Tutorial > Setting spaces in column names using MySQL?

Setting spaces in column names using MySQL?

王林
Release: 2023-09-14 23:25:06
forward
984 people have browsed it

使用 MySQL 设置列名中的空格?

To set spaces in column names in MySQL, you can use the concept of backticks. Let's first create a table. The following is the statement of 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)
Copy after login

The following is the query to insert some records in the table using the 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)
Copy after login

The following is the query to display all the records in the table using the select statement:

mysql> select `Student Id`,`Student Full Name` from blankSpacesDemo;
Copy after login

The following is the output showing spaces in the 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)
Copy after login

The above is the detailed content of Setting spaces in column names using MySQL?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template