我该如何修复 1064 错误
How can I fix 1064 error
我在尝试连接这两个表时遇到此错误
发生数据库错误错误号: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 'order, customer WHERE order.customer_id=customer.customer_id' at
line 2
查询:
SELECT order.order_id,order.order_total,
customer.first_name,customer.last_name FROM order, customer WHERE
order.customer_id=customer.customer_id;
文件名:
D:\xampp\htdocs\compulectronix2\system\database\DB_driver.php Line
Number: 330
"ORDER"是SQL中的保留字。你必须用反引号引用它:
SELECT
`order`.order_id,
`order`.order_total,
customer.first_name, customer.last_name
FROM `order`, customer
WHERE `order`.customer_id=customer.customer_id
每种语言都有一些保留词,我们也称它们为关键字。我们不能用这些保留字创建变量。
您的 table 名称是 'order',order 是 mysql 中的保留字,因此会产生 en 错误。你有两个选择
- 作为惯例,不要使用 mysql 保留字作为 table 名称,这样您就可以重命名 table.
如果你不想重命名 table 然后用 table 名称引用
和用户这样
SELECT
`order`.order_id,
`order`.order_total,
customer.first_name, customer.last_name
FROM `order`, customer
WHERE `order`.customer_id=customer.customer_id
希望对您有所帮助。编码愉快。
加入
SELECT `order`.`order_id`, `order`.`order_total`, `customer`.`first_name`, `customer`.`last_name`
FROM `order`
JOIN `customer` ON
`order`.`customer_id` = `customer`.`customer_id`;
没有加入
SELECT `order`.`order_id`, `order`. `order_total`,
`customer`.`first_name`, `customer`.`last_name`
FROM `order`, `customer`
WHERE `order`.`customer_id` = `customer`.`customer_id`;
我在尝试连接这两个表时遇到此错误
发生数据库错误错误号: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 'order, customer WHERE order.customer_id=customer.customer_id' at line 2
查询:
SELECT order.order_id,order.order_total,
customer.first_name,customer.last_name FROM order, customer WHERE
order.customer_id=customer.customer_id;
文件名:
D:\xampp\htdocs\compulectronix2\system\database\DB_driver.php Line Number: 330
"ORDER"是SQL中的保留字。你必须用反引号引用它:
SELECT
`order`.order_id,
`order`.order_total,
customer.first_name, customer.last_name
FROM `order`, customer
WHERE `order`.customer_id=customer.customer_id
每种语言都有一些保留词,我们也称它们为关键字。我们不能用这些保留字创建变量。
您的 table 名称是 'order',order 是 mysql 中的保留字,因此会产生 en 错误。你有两个选择
- 作为惯例,不要使用 mysql 保留字作为 table 名称,这样您就可以重命名 table.
如果你不想重命名 table 然后用 table 名称引用 和用户这样
SELECT `order`.order_id, `order`.order_total, customer.first_name, customer.last_name FROM `order`, customer WHERE `order`.customer_id=customer.customer_id
希望对您有所帮助。编码愉快。
加入
SELECT `order`.`order_id`, `order`.`order_total`, `customer`.`first_name`, `customer`.`last_name`
FROM `order`
JOIN `customer` ON
`order`.`customer_id` = `customer`.`customer_id`;
没有加入
SELECT `order`.`order_id`, `order`. `order_total`,
`customer`.`first_name`, `customer`.`last_name`
FROM `order`, `customer`
WHERE `order`.`customer_id` = `customer`.`customer_id`;