mysql update where some field is max

Posted by Syom on Stack Overflow See other posts from Stack Overflow or by Syom
Published on 2010-03-15T21:21:52Z Indexed on 2010/03/21 0:11 UTC
Read the original article Hit count: 741

Filed under:
|

The table videos has the following fields:

id | average | name 

How can i write the query, to update the name of video, which have the max average, or the second by size average!!! i can do that with two queries, by selecting the max(average) from the table, and then update the name, where ite average equal to max or to second value, but i want to do that in one query. i think the query must look like this UPDATE videos SET name = 'something' WHERE average = MAX(average)

Any suggestions?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about update