2012-01-30 52 views
0

我嘗試編寫代碼以查找最接近的值但我的代碼有一些syntex錯誤,請幫助
您的SQL語法有錯誤;檢查對應於你的MySQL服務器版本正確的語法在線路附近使用'7您的SQL語法中的mysql錯誤

update member t1 
    set Latid = (
     select id 
     from markersphuket t2 
     where t2.MU = t1.Moo 
     order by abs(t2.hno2 - t1.Hno2) 
     limit 1 
+1

你想關閉這個括號? '設置Latid =(' – Cheery 2012-01-30 06:31:50

回答

2

嘗試:

 

update member t1 
    set Latid = (
     select id 
     from markersphuket t2 
     where t2.MU = t1.Moo 
     order by abs(t2.hno2 - t1.Hno2) 
     limit 1) 
WHERE 1 // will update all the rows of member table 

 
0

嘗試手動:

update member t1 
set Latid = (
    select id 
    from markersphuket t2 
    where t2.MU = t1.Moo 
    order by abs(t2.hno2 - t1.Hno2) 
) 
    limit 1 
0

你錯過最後)

update member t1 
    set Latid = (
     select id 
     from markersphuket t2 
     where t2.MU = t1.Moo 
     order by abs(t2.hno2 - t1.Hno2) 
     limit 1 
    ) 
相關問題