मैं DISTINCT
का उपयोग कैसे करूँ total_time_driven_at_this_trip
के लिए सबसे अधिक मूल्य के साथ अद्वितीय प्रयोक्ता आईडी प्राप्त करने के लिए है और यह भी एक और मेज जिस पर user_id
आधारित संबंधों belongsto है से user_name
खींच?CakePHP DISTINCT
मैं इस कोशिश की ...
$this->set('tripNsws', $this->TripNsw->find('all',array('limit' => 20,'fields' => array('DISTINCT(TripNsw.user_id)','TripNsw.total_time_driven_at_this_trip'),'group' => array('TripNsw.user_id') ,'order' => array('TripNsw.total_time_driven_at_this_trip desc'))));
लेकिन यह काम नहीं कर रहा।
मैं तुम्हें नीचे प्राप्त करने की आवश्यकता लगता है ....
SELECT DISTINCT(user_id),`total_time_driven_at_this_trip` FROM `trip_nsws` order by `total_time_driven_at_this_trip` desc
मुझे नहीं लगता है कि आपका जवाब सवाल से संबंधित है - बिलकुल – mark