brown2005 Posted January 31, 2011 Share Posted January 31, 2011 SELECT DISTINCT(keywords_keyword), photos_extension FROM photos,photos_keywords,keywords,photos_websites WHERE photos_keywords_photo=photos_id AND photos_keywords_keyword=keywords_id AND photos_websites_website='3' ORDER BY keywords_keyword ASC this code gets all the correct websites, but I would like to get one website per keywords_keyword, how can I do this please? Link to comment https://forums.phpfreaks.com/topic/226266-help-display-one-result-for-each-keywords_keyword/ Share on other sites More sharing options...
The Letter E Posted January 31, 2011 Share Posted January 31, 2011 SELECT DISTINCT(keywords_keyword), photos_extension FROM photos,photos_keywords,keywords,photos_websites WHERE photos_keywords_photo=photos_id AND photos_keywords_keyword=keywords_id AND photos_websites_website='3' ORDER BY keywords_keyword ASC this code gets all the correct websites, but I would like to get one website per keywords_keyword, how can I do this please? Maybe... SELECT DISTINCT(keywords_keyword), photos_extension FROM photos,photos_keywords,keywords,photos_websites WHERE photos_keywords_photo=photos_id AND photos_keywords_keyword=keywords_id AND photos_websites_website='3' ORDER BY keywords_keyword ASC LIMIT 0, 1 This one might be better... SELECT DISTINCT(keywords_keyword), photos_extension FROM photos,photos_keywords,keywords,photos_websites WHERE photos_keywords_photo=photos_id AND photos_keywords_keyword=keywords_id AND photos_websites_website='3' ORDER BY RAND() LIMIT 0, 1 Link to comment https://forums.phpfreaks.com/topic/226266-help-display-one-result-for-each-keywords_keyword/#findComment-1168061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.