Home > Backend Development > PHP Tutorial > php编程SQL语句union all的使用编程

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

WBOY
Release: 2016-06-02 11:33:19
Original
1189 people have browsed it

编程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>
Copy after login
\n";

}
echo"

 

";
echo'';

}

mssql_close($conn);

}
?>

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template