我想从allinventory_tb得到描述和模型。
所以我做了内部连接,但是当我要显示描述和模型的时候。
错误是:
注意:未定义索引:描述,注意:未定义索引:模型。
有什么建议吗?
|allinventory_tb|
----------------
|in_code |
|description |
|model |
---------------
$sql = "select t.itemcode as itemcode ,sum(t.qty) as qty
from (
select itemcode,qty from barcode INNER JOIN allinventory_tb on barcode.itemcode = allinventory_tb.in_code
union all
select itemcode,qty from adjustment_tb INNER JOIN allinventory_tb on adjustment_tb.itemcode = allinventory_tb.in_code where adjustment_tb.status='APPROVED'
union all
select itemcode,(qty * -1) from soldout_pd INNER JOIN allinventory_tb on soldout_pd.itemcode = allinventory_tb.in_code) as t
group by itemcode";
$result = $conn->query($sql);发布于 2016-06-20 05:45:12
和您的查询,即
$sql = "select t.itemcode as itemcode ,sum(t.qty) as qty
from (
select itemcode,qty from barcode INNER JOIN allinventory_tb on barcode.itemcode = allinventory_tb.in_code
union all
select itemcode,qty from adjustment_tb INNER JOIN allinventory_tb on adjustment_tb.itemcode = allinventory_tb.in_code where adjustment_tb.status='APPROVED'
union all
select itemcode,(qty * -1) from soldout_pd INNER JOIN allinventory_tb on soldout_pd.itemcode = allinventory_tb.in_code) as t
group by itemcode";
$result = $conn->query($sql);您将无法访问description和model列值,因为您没有在查询中指定Re欲列名,所以当您尝试在PHP中访问查询结果时,您将得到如下通知错误:
注意:未定义索引:描述,注意:未定义索引:模型。
尝试这个查询
$sql = "select description,model,t.itemcode as itemcode ,sum(t.qty) as qty
from (
select description,model,itemcode,qty from barcode as bc INNER JOIN allinventory_tb as ait on bc.itemcode = ait.in_code
union all
select description,model,itemcode,qty from adjustment_tb as adt INNER JOIN allinventory_tb as ait1 on adt.itemcode = ait1.in_code where adjustment_tb.status='APPROVED'
union all
select description,model,itemcode,(qty * -1) from soldout_pd as slp INNER JOIN allinventory_tb as ait2 on slp.itemcode = ait2.in_code) as t
group by itemcode";
$result = $conn->query($sql);希望这对你有用..。
https://stackoverflow.com/questions/37915015
复制相似问题