[英]mysql_query minus 1 everything
I have a table, 3 columns, 我有一张桌子,三列,
ID (prmiary, auto-inc),counter (UNSIGNED INT), text (VARCHAR) ID(主要,自动递增),计数器(UNSIGNED INT),文本(VARCHAR)
There are 1 million rows. 有100万行。
I would like to go through the table and minus 1 from the counter value for each row (also, what happens if it is 0 and -1 happens [i set it as unsigned when I made the table? can a query handle this?). 我想遍历该表,并从每行的计数器值中减去1(同样,如果它为0且发生-1会发生什么情况(我在创建表时将其设置为无符号?查询可以处理吗?) 。
What is the best mysql_query to do this using php? 什么是使用php最好的mysql_query?
UPDATE table SET counter = counter - 1
WHERE counter > 0
It should just not update when counter - 1 < 0, iirc. 当计数器-1 <0,iirc时,它应该不更新。
我将使用UPDATE LOW_PRIORITY table SET counter = counter - 1 WHERE counter > 0;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.