Jose Luis F
Jose Luis F

Reputation: 3

UPDATE with SELECT and LIMIT

i am trying to do this example:

UPDATE box 
    SET idsector=19,
        fechaasignacion='2013-10-04 10:12:30', 
        resumen='bla bla bla', 
        palabrasclave='papapa papapapa',
        libre=0, publico=1 
WHERE idbox = (SELECT idbox FROM box WHERE libre=1 LIMIT 1);

i get this error "[Err] 1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'" but, reading mysql reference manual it supposed to work with LIMIT.

This query must update one field from table box and WHERE clause specify that must find and choose first field with value "libre=1". I hope you can understand

Upvotes: 1

Views: 75

Answers (1)

guessimtoolate
guessimtoolate

Reputation: 8642

why not use the where clause from subquery in your update query? Like so:

UPDATE box 
    SET idsector=19,
        fechaasignacion='2013-10-04 10:12:30', 
        resumen='bla bla bla', 
        palabrasclave='papapa papapapa',
        libre=0, publico=1 
WHERE libre=1 
LIMIT 1;

Upvotes: 1

Related Questions