在相同的时间选择更新所有行MYSQL

时间:2013-10-19 03:28:05

标签: mysql

我正在尝试更新并选择与以下相同的表格:

UPDATE tbl_domain SET remain = 
(SELECT DATEDIFF(expdate,NOW()) FROM (
SELECT DATEDIFF(expdate,NOW()) FROM tbl_domain 
) as x )  

我怎样才能让它发挥作用?有人请帮帮我!!!

1 个答案:

答案 0 :(得分:0)

试试这个:

UPDATE tbl_domain t, (SELECT DATEDIFF(expdate,NOW()) as remain
                        FROM tbl_domain 
                       ) t1
SET t.remain = t1.remain
-- WHERE t.Id = t1.Id --If you have some kind of unique id in your table.