php mysql update limit

后端 未结 2 1679
失恋的感觉
失恋的感觉 2021-01-23 20:57

I want to update mysql database, where directory = 0, and just update 5 of records which value 0 to art.

for explain:

2条回答
  •  终归单人心
    2021-01-23 21:27

    Your query doesn't seem wrong to me.

    But note that you might also want to specify an order by clause, to be sure which are the five "first" items :

    update articles
    set directory = 'art'
    where directory = '0'
    order by id
    limit 5
    


    Just as a reference : UPDATE Syntax

提交回复
热议问题