【发布时间】:2015-02-06 23:32:10
【问题描述】:
我是 MariaDB 的新手。
我有一张桌子。每行都有自己的有效性。
CREATE TABLE `tariff_table` (
`transportation_id` int(11) NOT NULL AUTO_INCREMENT,
`transporter` varchar(300) NOT NULL,
`valid_upto` date NOT NULL,
`expired_status` int(11) NOT NULL DEFAULT '0',
`status` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`transportation_id`)
)
表格结果:
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());
选择查询返回 2 行。
tariff_id
---------
1
3
在id的帮助下,我需要更新如下。
我需要以下结果。
tariff_id || transporter || valid_upto || expired_status || status
------------------------------------------------------------------
1 || Raj || 2014-12-08 || 1 || 0
3 || Mani || 2014-03-06 || 1 || 0
帮帮我。
【问题讨论】:
标签: mysql sql-update mariadb