PHP Programming SQL statement Use programming for UNION ALL

Source: Internet
Author: User
Keywords Programming PHP Information
Programming PHP Information


The IDs are ishijian1,ishijian2, and the statements are

Echo ';

?>

Start time

Cut-off time



c_huizong.php
Order Enquiry
if ($_post[' 1shijian1 ')
{
echo "
document.getElementById (' 1shijian1 '). value= ' ". $_post[' 1shijian1 '].
"';d Ocument.getelementbyid (' 1shijian2 '). value= '". $_post[' 1shijian2 '].
"'; Cg1name ();";

if ($_post[' 1shijian1 ']<>null)
$shijian 1= "and COPTC. tc003>= ". $_post[' 1shijian1 ');
Else
$shijian 1 = "";

if ($_post[' 1shijian2 ']<>null)
$shijian 2= "and COPTC. tc003<= ". $_post[' 1shijian2 ');
Else
$shijian 2 = "";

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 joins DDTJMX on Ma003=leixing and Xifen=xifen and SEWEN=DDTJMX. UDF10 and DDGM=DDGM and Daba=xinghao
Left joins 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 joins 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) R Kzs,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 joins COPTC on TC001=DDTJMX. TD001 and TC002=DDTJMX. TD002
Where xifen= ' and tc003>= ' 20150110 ' and tc003<= ' 20150120 '
GROUP by Leixing,bztdb ". $shijian 1. $shijian 2;

$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" ; ; ; ; ; ; ; ; ; ; ; The ; ; "; "; "; Echo "; Echo "; Echo "; Echo "; Echo "; Echo "; Echo "; Echo "; Echo "; Echo "; Echo "; Echo "; Tracking information
categorysubdivisionColor temperatureorder sizestandard ratio of single investmentTarget Shootingorder quantityexpected yieldtotal number of storagestandard warehousingquantity of goods soldnumber of pin backtracking Information
". $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)."Tracking information

";
Echo ';

}

Mssql_close ($conn);

}
?>

Now a running statement is wrong, is the following statement inside the query statement error, to correct.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.