robert_gsfame Posted July 31, 2010 Share Posted July 31, 2010 i have two tables assume question and answer question table consists of Question_Date, Question_id and Question_title answer table consists of Answer_Date, Question_id, Answer_id and Answer_title let say i have 1000 records and i wish to display only the last 100 records combining both question and answer. How can i do this with loop..any suggestion would be appreciate thx Link to comment https://forums.phpfreaks.com/topic/209406-loop-logical-problem/ Share on other sites More sharing options...
AbraCadaver Posted July 31, 2010 Share Posted July 31, 2010 Do it with the query not a loop: SELECT * FROM question, answer WHERE question.Question_id = answer.Question_id ORDER BY Answer_Date DESC LIMIT 100 Or ORDER BY Question_Date, not sure what you want. Link to comment https://forums.phpfreaks.com/topic/209406-loop-logical-problem/#findComment-1093420 Share on other sites More sharing options...
robert_gsfame Posted July 31, 2010 Author Share Posted July 31, 2010 what if i want display all records from both table which Question_id is equal to 7 how can i do that with your query as i cant find anywhere to put the condition there :confused: Link to comment https://forums.phpfreaks.com/topic/209406-loop-logical-problem/#findComment-1093421 Share on other sites More sharing options...
trq Posted July 31, 2010 Share Posted July 31, 2010 SELECT * FROM question, answer WHERE question.Question_id = answer.Question_id AND question.Question_id = 7 ORDER BY Answer_Date DESC LIMIT 100 Link to comment https://forums.phpfreaks.com/topic/209406-loop-logical-problem/#findComment-1093476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.