在 mysql 表名中使用 (-) 破折号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18670394/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
using (-) dash in mysql table name
提问by Shawon
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).
有没有办法用表名(temp_01-01-000001)解决这个问题。
采纳答案by hireSwish
You could edit line 132 of the file /system/database/drivers/mysql/mysql_utility.php
您可以编辑文件 /system/database/drivers/mysql/mysql_utility.php 的第 132 行
From:
从:
$query = $this->db->query("SELECT * FROM $table");
To:
到:
$query = $this->db->query("SELECT * FROM `$table`");
回答by Jhanvi
You have to add quotes as your table name contains number. I think the following query will work.
您必须添加引号,因为您的表名包含数字。我认为以下查询会起作用。
SELECT * FROM `temp_01-01-000001`