爱玺玺

爱玺玺的生活日记本。wx:lb87626

在sql语句select的结果中加内容,将 一个表的搜索结果加入到另一个表的搜索结果。

如果关联时逻辑很复杂,或者不知道有其它办法的情况下。

不得已可以使用下面的方法。

//正在拍卖

$sql = mysql_query("SELECT s.id,s.goodsname,s.starttime,s.keeptime,s.auctionprice,s.uid,s.goodspicshow,t.username,count(a.gid) pcount FROM shop_auction_list s

  Left JOIN t_users t ON s.uid=t.userid 

 left join auction_nowprice_history a on s.id=a.gid

 where  s.stock>0  and s.auctionprice>s.price group by s.id order by s.id desc limit 0,8");

while($rs=mysql_fetch_array($sql)){

$isf=$db->getone("select count(*) from shop_follow where gid='".$rs['id']."' and fuid='".$uid."' and isauc=1");

$rs["isf"]=$isf;

        $auctionsql[]=$rs;

}

$smarty->assign("nowtime",time());

$smarty->assign("auctionsql", $auctionsql);


发表评论:

Powered By Z-BlogPHP 1.4 Deeplue Build 150101

Copyright Your WebSite.Some Rights Reserved.

蜀ICP备11021721号-5