> 백엔드 개발 > PHP 튜토리얼 > php编程SQL语句union all的使用编程

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

WBOY
풀어 주다: 2016-06-02 11:33:19
원래의
1189명이 탐색했습니다.

编程php信息

图片说明
id分别是ishijian1,ishijian2,语句是

echo ' ';

?>

<code><td valign="top" style="width:903; "> <table border="0" cellspacing="1" cellpadding="1" align="center">
<tr>
<td title="格式:8位数字 示例:20131231默认搜索当前三个月内的订单要搜索之前的订单请修改或清空本项"><p align="center">起始时间</p></td>      <td title="格式:8位数字 示例:20131231默认搜索当前三个月内的订单要搜索之前的订单请修改或清空本项" width="165"></td>          </tr>
<tr>
<td title="格式:8位数字 示例:20140115"><p align="center">截止时间<br></p></td>      <td title="格式:8位数字 示例:20140115"></td>            <td><p align="center">                         </p></td>    </tr>
</table>
<p><br></p>
<br><p></p>
<p>c_huizong.php<br><?php <br>//订单查询<br>if ($_POST['1shijian1'])<br>{<br>echo "<br>document.getElementById('1shijian1').value='".$_POST['1shijian1'].<br>"';document.getElementById('1shijian2').value='".$_POST['1shijian2'].<br>"';cg1name();";</p>
<p>if ($_POST['1shijian1']NULL)<br>$shijian1=" and COPTC.TC003>=".$_POST['1shijian1'];<br>else<br>$shijian1="";</p>
<p>if ($_POST['1shijian2']NULL)<br>$shijian2=" and COPTC.TC003else<br>$shijian2="";</p>
<p>require_once('i_code/connect.php');</p>
<p>$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<br>FROM chaxun<br>LEFT JOIN DDTJMX ON MA003=leixing and xifen=XIFEN AND sewen=DDTJMX.UDF10 AND ddgm=DDGM and daba=XINGHAO <br>left join COPTC on TC001=DDTJMX.TD001 AND TC002=DDTJMX.TD002 <br>where xifen'' and xifen'5050' and TC003>='20150110' AND TC003GROUP BY leixing,xifen,sewen,ddgm,bztdb,daba<br>union all<br>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<br>FROM chaxun<br>LEFT JOIN DDTJMX ON MA003=leixing and xifen=XIFEN <br>left join COPTC on TC001=DDTJMX.TD001 AND TC002=DDTJMX.TD002 <br>where  xifen='5050' and TC003>='20150110' AND TC003GROUP BY leixing,xifen,bztdb<br>union all <br>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<br>FROM chaxun<br>LEFT JOIN DDTJMX ON MA003=leixing<br>left join COPTC on TC001=DDTJMX.TD001 AND TC002=DDTJMX.TD002 <br>where xifen='' and TC003>='20150110' AND TC003GROUP BY leixing,bztdb".$shijian1.$shijian2;</p>
<p>$result=mssql_query($query);<br>$row_num=mssql_num_rows($result);<br>if ($row_num0)<br>{<br>echo "</p>
<p></p>
<table align="center" cellspacing="0" cellpadding="0">
<br><tr align="center">";<br>echo "<th>类别</th>;<br><th>细分</th>;<br><th>色温</th>;<br><th>订单规模</th>;<br><th>标准投单比</th>;<br><th>打靶</th>;<br><th>订单量</th>;<br><th>预计产量</th>;<br><th>总入库数</th>;<br><th>标准入库</th>;<br><th>销货数量</th>;<br><th>销退数量</th>;<br><th>跟踪信息</th>;<br>
</tr>";<p>while($row=mssql_fetch_assoc($result))<br>{<br>    echo"</p>
<tr align="center">";<p>echo"</p>
<td>".$row['leixing']."</td>";<br>    echo"<td>".$row['xifen']."</td>";<br>    echo"<td>".$row['sewen']."</td>";<br>    echo"<td>".$row['ddgm']."</td>";<br>    echo"<td>".$row['bztdb']."</td>";<br>    echo"<td>".$row['daba']."</td>";<br>    echo"<td>".number_format($row['TD008'],0)."</td>";<br>    echo"<td>".number_format($row['TA015'],0)."</td>";<br>    echo"<td>".number_format($row['RKZS'],0)."</td>";<br>    echo"<td>".number_format($row['D310'],0)."</td>";<br>    echo"<td>".number_format($row['TH008'],0)."</td>";<br>    echo"<td>".number_format($row['TJ007'],0)."</td>";<br>    echo"<td>跟踪信息</td>";<br>    //跟踪信息<pre class="brush:php;toolbar:false"><code>echo"</code>
로그인 후 복사
\n";

}
echo"

 

";
echo'';

}

mssql_close($conn);

}
?>

现在一运行语句是错的,是后面的语句里面的查询语句有错,求指正。

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿