"/> ">

Home >Backend Development >PHP Tutorial >PHP里的sql有关问题

PHP里的sql有关问题

WBOY
WBOYOriginal
2016-06-13 12:05:251081browse

PHP里的sql问题

<br />//查询<br />	$sql="SELECT * FROM `rv_duifu` where 1=1 $search order by id desc LIMIT $pageNum,$numPerPage";<br />	$db->query($sql);<br />	$list=$db->fetchAll();<br />	<br />	//echo $sql;<br />	//格式化输出数据<br />	foreach($list as $key=>$val){<br />		if($key%2==0){<br />			$list[$key][rowcss]="listOdd";<br />		}else{<br />			$list[$key][rowcss]="listEven";<br />		}<br />		$sql_lc="select * from `rv_licai` where id='".$list[$key][licaiid]."' limit 1";<br />		$db->query($sql_lc);<br />		$row_lc=$db->fetchRow();<br />		$list[$key][name_txt]=$row_lc['name'];<br />		$list[$key][qixian_txt]=$row_lc['qixian'];<br />		$list[$key][bdate_txt]=$row_lc['bdate'];<br />		$list[$key][ldate_txt]=$row_lc['ldate'];<br />		$list[$key][jine_txt]=$row_lc['jine'];<br />	}<br /><br />	//模版<br />	$smt = new smarty();smarty_cfg($smt);<br />	$smt->assign('list',$list);<br />	$smt->assign('numPerPage',$_POST[numPerPage]); //显示条数<br />	$smt->assign('pageNum',$_POST[pageNum]); //当前页数<br />	$smt->assign('total',$total);<br />	$smt->assign('title',"列表");<br />	$smt->display('duifu_list.htm');<br />

上面有2条sql,我想用sqlserver把这两条sql拼接成一条sql语句,返回一个结果集?
------解决方案--------------------
你的数据库设计支持连表查询的话用join关键字应该就可以解决问题了
------解决方案--------------------
用Join来连表查询就行了。不明白的话,去查一下相关资料,这是SQL基础知识。
------解决方案--------------------
确定主表 数据都是以主表数据join为基础的

Statement:
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