felito Posted January 11, 2012 Share Posted January 11, 2012 I would like to know how can i limit the output by the number of id_offers and not the number of rows. For example SELECT A.id_offer, T.tags FROM offer A INNER JOIN offer_has_tags Z ON A.id_offer = Z.offer_id_offer INNER JOIN tags T ON Z.tags_id_tags = T.id_tags WHERE state = 0 ORDER BY date DESC LIMIT 0, 10 output: id_offer tags 77 xx 76 xx 76 xx 75 xx 75 xx 74 xx 74 xx 73 xx 73 xx 72 xx Link to comment https://forums.phpfreaks.com/topic/254830-limit-mysql-query/ Share on other sites More sharing options...
gin Posted January 12, 2012 Share Posted January 12, 2012 Use a LEFT JOIN instead of an INNER JOIN? Link to comment https://forums.phpfreaks.com/topic/254830-limit-mysql-query/#findComment-1306731 Share on other sites More sharing options...
felito Posted January 12, 2012 Author Share Posted January 12, 2012 this solve my problem SELECT A.id_offer, T.tags FROM ( SELECT * FROM offer WHERE state = 0 ORDER BY date DESC LIMIT 10 ) A JOIN offer_has_tags Z ON A.id_offer = Z.offer_id_offer JOIN tags T ON Z.tags_id_tags = T.id_tags Link to comment https://forums.phpfreaks.com/topic/254830-limit-mysql-query/#findComment-1306789 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.