我想更新mysql数据库,其中目录= 0,并且只更新5条记录,每条记录的值为0.
解释:
id | directory
1 | fashion
2 | 0 //update here into 'art'
3 | travel
4 | fashion
5 | 0 //update here into 'art'
6 | 0 //update here into 'art'
7 | travel
8 | 0 //update here into 'art'
9 | 0 //update here into 'art'
10 | 0 //this is 6th record, do not update, leave the value as '0'.
11 | fashion
这个更新代码正确吗?谢谢.
MysqL_query("UPDATE articles SET directory = 'art' WHERE directory ='0' LIMIT 5");
解决方法:
您的syntax很好.
ORDER BY `Id`
UPDATE articles SET directory = 'art' WHERE directory ='0' ORDER BY id LIMIT 5