Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using (-) dash in mysql table name

Tags:

mysql

There is an error while i want to backup my database

A Database Error Occurred  Error Number: 1064  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-01-000001' at line 1  SELECT * FROM temp_01-01-000001  Filename: F:\xampp\htdocs\erp_zaara\system\database\DB_driver.php  Line Number: 330 

Is there any way to solve this prob with the table name (temp_01-01-000001).

like image 464
Shawon Avatar asked Sep 07 '13 06:09

Shawon


People also ask

Can we use hyphen in table name in SQL?

No, the hyphen is an operator, and you can't use that in the middle of an identifier.

Does MySQL have minus operator?

MySQL Does not supports MINUS or EXCEPT ,You can use NOT EXISTS , NULL or NOT IN .

How do you do minus operations in MySQL?

Since MySQL does not provide support for MINUS operator. However, we can use a LEFT JOIN clause to simulate this operator. We can use the following syntax to simulate the MINUS operator: SELECT column_list FROM table1.

Can table name start with _?

Nope. Underscores are perfectly legal in table names.


1 Answers

You have to add quotes as your table name contains number. I think the following query will work.

SELECT * FROM `temp_01-01-000001` 
like image 195
Jhanvi Avatar answered Sep 21 '22 03:09

Jhanvi