0

I try to write a code to find the nearest value But my code have some syntex error please help
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 '' at line 7

  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
  • 1
    Do you want to close this parenthesis? set Latid = ( Commented Jan 30, 2012 at 6:31

3 Answers 3

2

TRy:


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


Sign up to request clarification or add additional context in comments.

Comments

0

Try:

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

Comments

0

Did you miss the last )?

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.