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

在我们开发的工程中,有时候会报

[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语句出现问题,下面我只说我经常犯的一种错误。当然还有很多种错误,我们遇到再说。
在这里插入图片描述

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

有时候sql语句大全也会出现这种错误 [Err] 1054 - Unknown column ‘----------’ in 'field list’
在这里插入图片描述

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

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

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值