gpt4 book ai didi

mysql - 此库存的数据值

转载 作者:行者123 更新时间:2023-11-29 11:30:29 25 4
gpt4 key购买 nike

我正在尝试找出该表上的变量:

enter image description here

我想遵循这个表的概念及其变量。我目前唯一知道并弄清楚的是日期应该使用时间戳你可以在进货、出货上使用类似邮票的东西吗现有库存?这样我就可以生成当天发生的任何变化的结果?

最佳答案

架构:

-- 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)

当然,我的 table 上可能有一个额外的日期。也许您只需要一个日期时间,就是这样(不是日期和日期时间)。但是,当对日期时间列使用 date() 函数时,它只会生成日期输出。因此请进行相应的实验。

关于mysql - 此库存的数据值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37505797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com