Shawon
Shawon

Reputation: 1030

using (-) dash in mysql table name

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).

Upvotes: 45

Views: 54440

Answers (2)

You could edit line 132 of the file /system/database/drivers/mysql/mysql_utility.php

From:

$query = $this->db->query("SELECT * FROM $table");

To:

$query = $this->db->query("SELECT * FROM `$table`");

Upvotes: 28

Jhanvi
Jhanvi

Reputation: 5139

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

SELECT * FROM `temp_01-01-000001`

Upvotes: 74

Related Questions