Deleting a row based on the max value

前端 未结 4 1259
我在风中等你
我在风中等你 2020-12-03 18:23

How can I structure a mySQL query to delete a row based on the max value.

I tried

WHERE jobPositonId = max(jobPostionId)

but got

4条回答
  •  盖世英雄少女心
    2020-12-03 18:53

    This works:

    SELECT @lastid := max(jobPositonId ) from t1; 
    DELETE from t1 WHERE jobPositonId = @lastid ; 
    

    Other than going to the database twice, is there anything wrong with this technique?

提交回复
热议问题