天天看點

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] 1064 – You have an error in your SQL syntax; check the manual that corresponds to your

這時候 我們不難發現 錯誤的原因是我們這裡多了一個 ,号

有時候也會出現這種錯誤 [Err] 1054 – Unknown column ‘———-’ in ‘field list’

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

這時候是我們的字段寫錯了 我們會發現資料庫中并沒有這個字段 而是我們的字段寫錯了

下面為大家寫上兩個同級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           

複制

釋出者:全棧程式員棧長,轉載請注明出處:https://javaforall.cn/130032.html原文連結:https://javaforall.cn