开发者

Mysql left join limit

开发者 https://www.devze.com 2023-02-27 01:21 出处:网络
I am trying to limit the last left join to only 1 result $query=\"SELECT a.*, cc.name AS category, ee.ezcity AS proploc

I am trying to limit the last left join to only 1 result

$query="SELECT a.*, cc.name AS category, ee.ezcity AS proploc
       , dd.name AS statename, bb.name AS countryname
       , u.logo_image AS logo_image, u.mid AS mid
       , u.dealer_name AS dealer_name, u.dealer_company AS dealer_company
       , u.dealer_phone AS dealer_phone, u.dealer_mobile AS dealer_mobile
       , u.published AS dealerpublished, sp.tenant AS tenant
       , sp.spacenum AS spacenum, sp.sf AS sf, sp.image AS tenantimage
       , u.dealer_type AS dealer_type 
     FROM #__ezrealty as a"
    . "\n LEFT JOIN #__ezrealty_catg AS cc ON cc.id = a.cid"
    . "\n LEFT JOIN #__ezrealty_locality AS ee ON ee.id = a.locid"
    . "\n LEFT JOIN #__ezrealty_state AS dd ON dd.id = a.stid"
    . "\n LEFT JOIN #__ezrealty_country AS bb ON bb.id = a.cnid"
    . "\n LEFT JOIN #__ezrealty_profile AS u ON u.mid = a.owner"
    . "\n LEFT JOIN #__ez开发者_JAVA技巧realty_siteplan AS sp ON sp.listing_id = a.id "
    . "\n WHERE $extrastring AND a.published = '1' $vacant 
          AND cc.access <= $my->gid $wheres "
    . $order.' LIMIT '.$pageNav->limitstart.', '.$pageNav->limit;

I have tried :

. "\n  LEFT JOIN (SELECT listing_id FROM #__ezrealty_siteplan LIMIT 1) sp 
         ON sp.listing_id = a.id"


I think your result look like it contains more than 1 because the results are not GROUP BY any column.

0

精彩评论

暂无评论...
验证码 换一张
取 消