mysql - 此库存的数据值

标签 mysql

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

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/

相关文章:

mysql - 使用 solr 索引和搜索 MySQL

mysql - 跟踪访问与动态目标的数据库

php - "Undefined variable"当php函数从mysql数据值中选择时

php - Doctrine 查询生成器 : ManyToOne Relationship where more than one subEntity must match

PHP 脚本在 Internet Explorer 和 Firefox 中不起作用

php - PDO 预准备语句的功能不起作用并出现错误

mysql - 64位系统通过odbc连接mysql

mysql - BASH - 如何读取文件内容以将结果插入 mysql WHERE 子句

php - 表单提交 PHP 代码仅在 WordPress 中损坏

php - 如何在 codeigniter 的模型中按 ID 调用多个类别?