mysql 创建视图 多表,MySql-创建视图以从多个表中读取

本文介绍如何在MySQL中创建视图来合并`Invoice`表和两个`LineItem`表的数据,以便查询已发送发票的总额及其所有行项目。通过创建一个名为`Invoice_LineItem_All`的MERGE存储引擎表,可以实现从两个LineItem表中检索所有行项目。
摘要由CSDN通过智能技术生成

I have archived some old line items for invoices that are no longer current but still need to reference them. I think I need to create a VIEW but not really understanding it. Can someone help so I can run a query to pull the invoice and then the total of all the line items assigned (no matter what table the items are in)?

CREATE TABLE `Invoice` (

`Invoice_ID` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,

`Invoice_CreatedDateTime` DATETIME DEFAULT NULL,

`Invoice_Status` ENUM('Paid','Sent','Unsent','Hold') DEFAULT NULL,

`LastUpdatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

PRIMARY KEY (`ID`),

KEY `LastUpdatedAt` (`LastUpdatedAt`)

) ENGINE=MYISAM DEFAULT CHARSET=latin1

CREATE TABLE `Invoice_L

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值