php編程SQL語句union all的使用編程

來源:互聯網
上載者:User
關鍵字 編程 php 資訊
編程php資訊


id分別是ishijian1,ishijian2,語句是

echo ' ';

?>

起始時間

截止時間

 



c_huizong.php
//訂單查詢
if ($_POST['1shijian1'])
{
echo "
document.getElementById('1shijian1').value='".$_POST['1shijian1'].
"';document.getElementById('1shijian2').value='".$_POST['1shijian2'].
"';cg1name();";

if ($_POST['1shijian1']<>NULL)
$shijian1=" and COPTC.TC003>=".$_POST['1shijian1'];
else
$shijian1="";

if ($_POST['1shijian2']<>NULL)
$shijian2=" and COPTC.TC003<=".$_POST['1shijian2'];
else
$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 TC003<='20150120'
GROUP 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 TC003<='20150120'
GROUP 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 TC003<='20150120'
GROUP BY leixing,bztdb".$shijian1.$shijian2;

$result=mssql_query($query);
$row_num=mssql_num_rows($result);
if ($row_num<=10000 && $row_num>0)
{
echo "
















while($row=mssql_fetch_assoc($result))
{
echo"

echo"














echo"
\n";

}
echo"

";echo " ; ; ; ; ; ; ; ; ; ; ; ; ; "; "; "; echo" "; echo" "; echo" "; echo" "; echo" "; echo" "; echo" "; echo" "; echo" "; echo" "; echo" "; echo" "; //跟蹤資訊
類別細分色溫訂單規模標準投單比打靶訂單量預計產量總入庫數標準入庫銷貨數量銷退數量跟蹤資訊
".$row['leixing']."".$row['xifen']."".$row['sewen']."".$row['ddgm']."".$row['bztdb']."".$row['daba']."".number_format($row['TD008'],0)."".number_format($row['TA015'],0)."".number_format($row['RKZS'],0)."".number_format($row['D310'],0)."".number_format($row['TH008'],0)."".number_format($row['TJ007'],0)."跟蹤資訊

 

";
echo'';

}

mssql_close($conn);

}
?>

現在一運行語句是錯的,是後面的語句裡面的查詢語句有錯,求指正。

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.