答案 0 :(得分:1)
模式:
-- drop table if exists inventory;
create table inventory
( itemId varchar(20) primary key, -- you choose the sizings
theDate date not null, -- not this is just a date, not a datetime. It follows your picture info
description varchar(200) not null, -- you choose the sizings
stockIn int not null,
stockOut int not null,
onHand int not null,
updtDT datetime not null
)ENGINE=InnoDB;
加载测试数据:
insert inventory(itemId,theDate,description,stockIn,stockOut,onHand,updtDt) values
('6222-B','2014-09-27','Device 5',0,200,600,'2016-04-10 12:00'),
('9000-M','2014-09-27','Widget 1001',0,400,1800,'2016-04-10 12:00'),
('9000-XX','2014-09-28','Gadget 12',0,200,1650,'2016-04-10 12:00');
触摸包含更新数据的行:
update inventory
set onHand=1900,updtDt=now()
where itemId='9000-XX';
显示今天更新的数据:
select * from inventory where date(updtDt)=current_date();
+---------+------------+-------------+---------+----------+--------+---------------------+
| itemId | theDate | description | stockIn | stockOut | onHand | updtDT |
+---------+------------+-------------+---------+----------+--------+---------------------+
| 9000-XX | 2014-09-28 | Gadget 12 | 0 | 200 | 1900 | 2016-05-29 00:24:51 |
+---------+------------+-------------+---------+----------+--------+---------------------+
1 row in set (0.00 sec)
当然,我的桌子上可能有额外的约会。也许你只需要一个日期时间就是它(不是日期和日期时间)。但是date()
函数在对datetime列使用时,只会生成日期输出。所以进行相应的实验。
答案 1 :(得分:0)
我不确定你要问的是什么,但你提到的列的数据类型应该是INTEGER