前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >sql语句 异常 Err] 1064 – You have an error in your SQL syntax; check the manual that corresponds to your

sql语句 异常 Err] 1064 – You have an error in your SQL syntax; check the manual that corresponds to your

作者头像
全栈程序员站长
发布2022-08-10 13:27:13
发布2022-08-10 13:27:13
6.1K00
代码可运行
举报
运行总次数:0
代码可运行

大家好,又见面了,我是你们的朋友全栈君。

在我们开发的工程中,有时候会报 [Err] 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 —— 这种异常 不用多想,肯定是我们的sql语句出现问题,下面我只说我经常犯的一种错误。当然还有很多种错误,我们遇到再说。

这时候 我们不难发现 错误的原因是我们这里多了一个 ,号

有时候也会出现这种错误 [Err] 1054 – Unknown column ‘———-’ in ‘field list’

这时候是我们的字段写错了 我们会发现数据库中并没有这个字段 而是我们的字段写错了

下面为大家写上两个同级sql

代码语言:javascript
代码运行次数:0
运行
复制
select a.Attribute_Id as Attribute_Id,          
       a.Attribute_Name as Attribute_Name,      
       a.Attribute_Alias as Attribute_Alias,
       a.Attribute_Unit as Attribute_Unit,
       a.DeviceType_Id as DeviceType_Id,
       a.SortCode as SortCode,
       a.UpdateTime as UpdateTime,   
       a.isdel as isDel
			from  zz_deviceattribute as a
where   Attribute_Id in(
select Attribute_Id from ZZ_DeviceAttributeRelation
where Device_Id =  '05871a37-a242-40f9-bbea-33bdea7009d5')
代码语言:javascript
代码运行次数:0
运行
复制
 select distinct 
 				a.Attribute_Id as Attribute_Id,
				a.Attribute_Name as Attribute_Name,
				a.Attribute_Alias as Attribute_Alias,
				a.Attribute_Unit as Attribute_Unit,
				a.DeviceType_Id as DeviceType_Id,
				a.SortCode as SortCode,
				a.UpdateTime as UpdateTime,   
				a.isdel as isDel        
		from ZZ_DeviceAttributeRelation  as b
				inner join zz_deviceattribute as a 
				on a.Attribute_Id = b.Attribute_Id
				where b.Device_Id =  '05871a37-a242-40f9-bbea-33bdea7009d5'
				and a.isDel ='0'
				order by a.SortCode

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/130032.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年4月2,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档