Mysql 如何在MariaDB中选定行的帮助下更新列值?
我是新来的 我有一张桌子。每行都有自己的有效性 表格结果: 我的要求是,如何使用select查询更新过期状态 在id的帮助下,我需要更新如下 我需要下面的结果 帮助我。在关键字中使用 或 您可以使用UPDATE语句,如下所示:Mysql 如何在MariaDB中选定行的帮助下更新列值?,mysql,sql-update,mariadb,Mysql,Sql Update,Mariadb,我是新来的 我有一张桌子。每行都有自己的有效性 表格结果: 我的要求是,如何使用select查询更新过期状态 在id的帮助下,我需要更新如下 我需要下面的结果 帮助我。在关键字中使用 或 您可以使用UPDATE语句,如下所示: UPDATE `tariff_table` SET `expired_status` = 1 WHERE valid_upto <= DATE(now()); tariff_id || transporter || valid_upto || expired_st
UPDATE `tariff_table`
SET `expired_status` = 1
WHERE valid_upto <= DATE(now());
tariff_id || transporter || valid_upto || expired_status || status
------------------------------------------------------------------
1 || Raj || 2014-12-08 || 0 || 0
2 || Ram || 2015-01-10 || 0 || 0
3 || Mani || 2014-03-06 || 0 || 0
4 || Mano || 2015-04-15 || 0 || 0
select tariff_id from tariff_table where valid_upto <= DATE(now());
tariff_id
---------
1
3
tariff_id || transporter || valid_upto || expired_status || status
------------------------------------------------------------------
1 || Raj || 2014-12-08 || 1 || 0
3 || Mani || 2014-03-06 || 1 || 0
UPDATE tariff_table SET expired_status = 1 WHERE tariff_id
IN(select tariff_id from tariff_table where valid_upto <= DATE(now()))
UPDATE tariff_table SET expired_status = 1 WHERE valid_upto <= DATE(now())
UPDATE `tariff_table`
SET `expired_status` = 1
WHERE valid_upto <= DATE(now());