2011-07-28 47 views
0

表unit_inward查詢用於在MySQL添加兩個表的內容

id supplier_inward_id unit_id supplied_by supplied_qty supplied_date created_date  is_processed 
427 1929    UI822900 manager  15   2011-07-06  2011-07-26 18:33:37 No 
426 1929    UI822900 manager  15   2011-07-06  2011-07-26 18:33:37 No 
429 1929    UI988354 manager  35   2011-07-14  2011-07-27 10:49:21 No 
428 1929    UI988354 manager  15   2011-07-14  2011-07-27 10:49:21 No 
430 1929    UI600839 manager  10   2011-07-15  2011-07-27 10:56:01 No 
431 1929    UI600839 manager  10   2011-07-15  2011-07-27 10:56:01 No 
432 1929    UI562771 manager  10   2011-07-15  2011-07-27 10:56:01 No 
434 1929    UI600839 manager  10   2011-07-18  2011-07-28 12:52:53 No 

表unit_inward_details

id supplier_inward_id unit_inward_id barcode  product_unit assign_volume total_qty supplied_date created_date 
    4  1929    427  8904032004628 5     2    10   2011-07-06 2011-07-26 18:33:37 
    3  1929    426  8906032010012 1     5    5   2011-07-06 2011-07-26 18:33:37 
    5  1929    428  8904032004628 5     1    5   2011-07-14 2011-07-27 10:49:21 
    6  1929    429  8906032010135 15     2    30   2011-07-14 2011-07-27 10:49:21 
    7  1929    430  8906032010012 1     5    5   2011-07-15 2011-07-27 10:56:01 
    8  1929    431  8904032004628 5     1    5   2011-07-15 2011-07-27 10:56:01 
    9  1929    432  8904032004628 5     2    10   2011-07-15 2011-07-27 10:56:01 
    11  1929    434  8904032004628 5     2    10   2011-07-18 2011-07-28 12:52:53 

我需要一個查詢,其可以使用添加的product_unit,assign_volume和total_qty內容從這兩個表提供的日期...如何實現這一目標?假設如果創建日期是

2011-07-15

它應該顯示在一排加起來差不多所有的table.Output的總和此表

supplier_inward_id unit_id supplied_qty supplied_date is_processed barcode product_unit assign_volume total_qty 
    1929   UI600839  10  2011-07-15    No  8906032010012  2  10    10 

1929   UI600839  10  2011-07-18    No  8904032004628  5  2    10 
+0

SELECT a.supplier_inward_id,a.unit_id,a.supplied_qty,a.supplied_date,a.is_processed,b.barcode,b.product_unit,b.assign_volume,b.total_qty FROM unit_inward一個,unit_inward_details b其中a.unit_id ='UI600839'AND a.supplied_date = b.supplied_date AND a.id = b.unit_inward_id ORDER BY a.id asc limit 0,15 – user855492

+0

以及錯誤/輸出是什麼? – k102

+0

無法添加類似日期的內容.... – user855492

回答

0

您可以在MySql中查詢Mnay結構和查詢 By UNION

示例:

(SELECT *FORM...) UNION (INSERT INTO ...) UNIO