如何在某个产品日期之间使用两个连接表? [英] How do I loop two join table using between certain product date ?

查看:102
本文介绍了如何在某个产品日期之间使用两个连接表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在某个产品日期之间循环使用两个连接表?



首先,表格



How do i loop two join table using between certain product date ?

First, the table

Table Product
MO_code | product_code |  product_name   | product_qty | product_date
-------------------------------------------------------------------------
MO0001       A00001        Cup_Box 3x3          9       2016-04-01

< br $>




Table item
MO_codex | item_code |  item_name   | item_qty |
--------------------------------------------------
MO0001    Aa00001      cup_red         3
MO0001    Ab00001      cup_blue        3
MO0001    Ac00001      cup_green       3





如您所见,产品A00001由表项目中的项目组成。现在,我想制作一个报告,将这两个表组合起来并从特定日期范围循环。我已经创建了查询,但很难创建打印输出报告。你可以教我算法,所以它在php上显示这样的表格。





as you can see, product A00001 is made from item in table item. Now, i want to make a report which combine these 2 tables and loop it from specific date range. I already create the query but having a hard time to create print out report. Can u teach me the algorithm so it show table on php like this..

MO_code|product_code|product_name|product_qty|item_code|item_name|item_qty|
---------------------------------------------------------------------------
MO0001    A0001      Cup_box 3x3       9     |  Aa00001    cup_red     3
                                             |  Ab00001    cup_blue    3
                                             |  Ac00001    cup_green   3





我的尝试:



到目前为止,这是我已经尝试过的。假设已经制作了$ connSQL



$ sql =SELECT a.MO_code,a.product_code,a.product_name,a.product_qty,b.item_code,b.item_name FROM产品a.MO_code = b.MO_codex上的连接项目b,其中;

$ product = odbc_exec($ connSQL,$ sql);



while($ fetch_prod = odbc_fetch_array($ product))

{

... //这是产品打印的地方

而()

{

... //这是项目

}

}



What I have tried:

So far, this is i've been tried. Just assume $connSQL already made

$sql = "SELECT a.MO_code, a.product_code, a.product_name, a.product_qty, b.item_code, b.item_name FROM Product a join item b on a.MO_code = b.MO_codex where ";
$product = odbc_exec($connSQL, $sql);

while ($fetch_prod = odbc_fetch_array($product))
{
...//this is where product was print
while ()
{
...//this is where item
}
}

推荐答案

connSQL已经制作


connSQL already made


sql =SELECT a.MO_code,a。 product_code,a.product_name,a.product_qty,b.item_code,b.item_name FROM产品a.MO_code = b.MO_codex上的连接项b其中;
sql = "SELECT a.MO_code, a.product_code, a.product_name, a.product_qty, b.item_code, b.item_name FROM Product a join item b on a.MO_code = b.MO_codex where ";


product = odbc_exec(
product = odbc_exec(


这篇关于如何在某个产品日期之间使用两个连接表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆