开发者

Query for adding the contents of two table in mysql

Table unit_inward

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开发者_如何学C-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

Table 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

I need a query which can add the contents of product_unit ,assign_volume and total_qty using the supplied date from this two tables... how to achieve this??? suppose if the created date is

2011-07-15

it should show in one row adding up all the sum of the table.Output similar to this table

 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


You Can Query Mnay structs And Query's in MySql By UNION

Example:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜