SQL-related issues in PHP

Source: Internet
Author: User
SQL Issues in PHP

Inquire
$sql = "SELECT * from ' Rv_duifu ' where 1=1 $search the ORDER by id desc LIMIT $pageNum, $numPerPage";
$db->query ($sql);
$list = $db->fetchall ();

Echo $sql;
Format output data
foreach ($list as $key = = $val) {
if ($key%2==0) {
$list [$key][rowcss]= "listodd";
}else{
$list [$key][rowcss]= "Listeven";
}
$sql _lc= "select * from ' Rv_licai ' where id= '". $list [$key][licaiid]. "' Limit 1 ';
$db->query ($sql _lc);
$row _lc= $db->fetchrow ();
$list [$key][name_txt]= $row _lc[' name '];
$list [$key][qixian_txt]= $row _lc[' Qixian '];
$list [$key][bdate_txt]= $row _lc[' bdate '];
$list [$key][ldate_txt]= $row _lc[' ldate '];
$list [$key][jine_txt]= $row _lc[' jine '];
}

Templates
$SMT = new Smarty (); smarty_cfg ($SMT);
$smt->assign (' list ', $list);
$smt->assign (' Numperpage ', $_post[numperpage]); Show number of bars
$smt->assign (' Pagenum ', $_post[pagenum]); Current page
$smt->assign (' Total ', $total);
$smt->assign (' title ', ' list ');
$smt->display (' duifu_list.htm ');

There are 2 SQL, I want to use SQL Server to stitch the two SQL into an SQL statement, return a result set?
------Solution--------------------
Your database design supports even table queries, and the JOIN keyword should solve the problem.
------Solution--------------------
It's OK to use join to query the table. Do not understand, to check the relevant information, this is the basic knowledge of SQL.
------Solution--------------------
Determines that the primary table data is based on the primary table data join
  • 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.