我想在这里提出一个问题......让我解释一下... 这里我有3个表, 1. transaction_table 2. transaction_detail 3项mysql的项目销售
不,我这里的问题是我想知道的项目本月销售(2013-01)中的示例中,这里是我的表结构...
1交易表
--------------------------
idTransaction | date | idUser | idCustomer | total | NOSC
--------------------------------------------------------------------
1 | 2013-01-01 | 3 | 4 | 500000 | 1CO
2 | 2013-01-01 | 3 | 5 | 450000 | 2CO
3 | 2013-01-01 | 3 | 6 | 250000 | 3CO
2 transaction_detail
-----------------------------------------------------------------
idTransaction | idItem | qty | price
----------------------------------------
1 | 1 | 2 | 250000
2 | 2 | 1 | 250000
2 | 3 | 1 | 200000
3 | 1 | 1 | 250000
3项表
idItem | Name Item
---------------------------------------
1 | glass
2 | Medicine A
3 | Medicine B
4客户
idCustomer | Name Customer
--------------------------------------
4 | Abuh
5 | Abeh
6 | ABooh
因此,基于这些表我想获得这样的数据....
Name Item | Nosc | Customer | Sold Quantity | @ Price | Total
---------------------------------------------
Glass | 1CO | Abuh |2 | 250000 | 500000
Glass | 3CO | ABooh |1 | 250000 | 250000
Medicine A| 2CO | Abeh |1 | 250000 | 250000
Medicine B| 2CO | Abeh |1 | 200000 | 200000
任何人都可以帮助我?
我需要使用从事务表的日期..查询的方式是什么? –
@WawanBrutalx你需要加入'Transaction'表。 [** >> CLICK_HERE << **](http://www.sqlfiddle.com/#!2/f7090/5) –
我的后续问题如何? –