您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php编程SQL语句union all的使用编程

2024/3/20 13:34:34发布22次查看
编程php信息
id分别是ishijian1,ishijian2,语句是
起始时间
截止时间
c_huizong.php
=.$_post['1shijian1'];
else
$shijian1=;
if ($_post['1shijian2']null)
$shijian2= and coptc.tc003else
$shijian2=;
require_once('i_code/connect.php');
$query=select leixing,xifen,sewen,ddgm,bztdb,daba,sum(td008) as td008,sum(ta015)ta015,sum(rkzs)rkzs,sum(d310)d310,sum(d305)d305,sum(d304)d304,sum(d3023)d3023,sum(th008)th008,sum(tj007)tj007
from chaxun
left join ddtjmx on ma003=leixing and xifen=xifen and sewen=ddtjmx.udf10 and ddgm=ddgm and daba=xinghao
left join coptc on tc001=ddtjmx.td001 and tc002=ddtjmx.td002
where xifen'' and xifen'5050' and tc003>='20150110' and tc003group by leixing,xifen,sewen,ddgm,bztdb,daba
union all
select leixing,xifen,null as sewen,null as ddgm,bztdb,null as daba,sum(td008) as td008,sum(ta015)ta015,sum(rkzs)rkzs,sum(d310)d310,sum(d305)d305,sum(d304)d304,sum(d3023)d3023,sum(th008)th008,sum(tj007)tj007
from chaxun
left join ddtjmx on ma003=leixing and xifen=xifen
left join coptc on tc001=ddtjmx.td001 and tc002=ddtjmx.td002
where xifen='5050' and tc003>='20150110' and tc003group by leixing,xifen,bztdb
union all
select leixing,null as xifen,null as sewen,null as ddgm,bztdb, null as daba,sum(td008) as td008,sum(ta015)ta015,sum(rkzs)rkzs,sum(d310)d310,sum(d305)d305,sum(d304)d304,sum(d3023)d3023,sum(th008)th008,sum(tj007)tj007
from chaxun
left join ddtjmx on ma003=leixing
left join coptc on tc001=ddtjmx.td001 and tc002=ddtjmx.td002
where xifen='' and tc003>='20150110' and tc003group by leixing,bztdb.$shijian1.$shijian2;
$result=mssql_query($query);
$row_num=mssql_num_rows($result);
if ($row_num0)
{
echo
;
echo 类别;
细分;
色温;
订单规模;
标准投单比;
打靶;
订单量;
预计产量;
总入库数;
标准入库;
销货数量;
销退数量;
跟踪信息;
;while($row=mssql_fetch_assoc($result))
{
echo
;echo
.$row['leixing']. ;
echo.$row['xifen']. ;
echo.$row['sewen']. ;
echo.$row['ddgm']. ;
echo.$row['bztdb']. ;
echo.$row['daba']. ;
echo.number_format($row['td008'],0). ;
echo.number_format($row['ta015'],0). ;
echo.number_format($row['rkzs'],0). ;
echo.number_format($row['d310'],0). ;
echo.number_format($row['th008'],0). ;
echo.number_format($row['tj007'],0). ;
echo跟踪信息 ;
//跟踪信息echo
\n;}
echo
;
echo'';}
mssql_close($conn);
}
?>
现在一运行语句是错的,是后面的语句里面的查询语句有错,求指正。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product