Home > Database > Mysql Tutorial > How to select data from a table with spaces in the table name in MYSQL?

How to select data from a table with spaces in the table name in MYSQL?

PHPz
Release: 2023-09-03 11:13:06
forward
900 people have browsed it

How to select data from a table with spaces in the table name in MYSQL?

If the table name has spaces, you need to use backticks around the table name. Let's first create a table.

Here, we have used backtick-

mysql> create table `Demo Table138`
(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   Price int
);
Query OK, 0 rows affected (0.47 sec)
Copy after login

Use insert command to insert records in table-

mysql> insert into `Demo Table138`(Price) values(450);
Query OK, 1 row affected (0.18 sec)
mysql> insert into `Demo Table138`(Price) values(499);
Query OK, 1 row affected (0.16 sec)
mysql> insert into `Demo Table138`(Price) values(199);
Query OK, 1 row affected (0.17 sec)
mysql> insert into `Demo Table138`(Price) values(3090);
Query OK, 1 row affected (0.21 sec)
Copy after login

Use select command to display records in table-

The following is a query to select data from a table that contains spaces in the table name-

mysql> select *from `Demo Table138`;
Copy after login

This will produce the following output-

+----+-------+
| Id | Price |
+----+-------+
| 1  | 450   |
| 2  | 499   |
| 3  | 199   |
| 4  | 3090  |
+----+-------+
4 rows in set (0.00 sec)
Copy after login

The above is the detailed content of How to select data from a table with spaces in the table name in 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