mysql - SQL 错误 1064 [英] mysql - SQL Error 1064

查看:71
本文介绍了mysql - SQL 错误 1064的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从这两个表中进行内部连接查询,但每次都出现错误.客户表包括 custId、custName、custPhone(custId 是 PK)订单表由 orderId,custId,orderDate 组成(orderId 为 PK,custId 为 FK)错误是:

I tried to make a inner join query from these two tables but I get error every time. customer table consist custId,custName,custPhone (custId is PK) order table consist orderId,custId,orderDate (orderId is PK and custId is FK) the error is :

1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 2 行的order On customer.custId=order.custId LIMIT 0, 30"附近使用的正确语法

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 On customer.custId=order.custId LIMIT 0, 30' at line 2

Select * From customer 
Inner Join order
On customer.custId=order.custId

推荐答案

Order 是保留字.用反引号 '`' 将其括起来

Order is a reserved word. Surround it with back quotes '`'

Select * From customer 
Inner Join `order`
On customer.custId=`order`.custId

不鼓励使用保留字作为对象名称.最好将其更改为其他可接受的名称,例如 orderscustomer_orders 或其他名称.

Usage of reserved words as object names is not encouraged. Better change it to some other acceptable name like orders or customer_orders, or something else.

参考:MySQL 保留字

这篇关于mysql - SQL 错误 1064的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆