0

次のクエリで個別の検索を行う必要があります。

$listings = $this->Listing->query("SELECT DISTINCT(Listing.listnumber),Listing.*, ClientEvent.*, Client.*, UserLog.*, Agent.* FROM listings Listing
                        LEFT JOIN client_events ClientEvent ON ClientEvent.listnumber = Listing.listnumber
                        LEFT JOIN clients Client ON Client.clnt_id = ClientEvent.clnt_id
                        LEFT JOIN user_logs UserLog ON UserLog.ul_item_id = Listing.listnumber
                        LEFT JOIN agents Agent ON Agent.agnt_id = Listing.agnt_id
                        WHERE Listing.off_id = '{$off_id}' AND (UserLog.ul_type = 'listing.new_listing' OR Listing.listnumber LIKE '3330%')");

ただし、これにより正しい結果が得られますが、重複します。DISTINCT の結果が必要です。

何か案は?

4

1 に答える 1

-1
    $listings = $this->Listing->query("SELECT Listing.listnumber FROM listings Listing
                            LEFT JOIN client_events ClientEvent ON ClientEvent.listnumber = Listing.listnumber
                            LEFT JOIN clients Client ON Client.clnt_id = ClientEvent.clnt_id
                            LEFT JOIN user_logs UserLog ON UserLog.ul_item_id = Listing.listnumber
                            LEFT JOIN agents Agent ON Agent.agnt_id = Listing.agnt_id
                            WHERE Listing.off_id = '{$off_id}' AND (UserLog.ul_type = 'listing.new_listing' OR Listing.listnumber LIKE '3330%') group by Listing.listnumber");
----------------------
Put your extar column not a tablename.*...

    $listings = $this->Listing->query("SELECT Listing.listnumber, colname1,.. FROM listings Listing
                            LEFT JOIN client_events ClientEvent ON ClientEvent.listnumber = Listing.listnumber
                            LEFT JOIN clients Client ON Client.clnt_id = ClientEvent.clnt_id
                            LEFT JOIN user_logs UserLog ON UserLog.ul_item_id = Listing.listnumber
                            LEFT JOIN agents Agent ON Agent.agnt_id = Listing.agnt_id
                            WHERE Listing.off_id = '{$off_id}' AND (UserLog.ul_type = 'listing.new_listing' OR Listing.listnumber LIKE '3330%') group by Listing.listnumber");
于 2012-10-11T09:57:56.987 に答える