mcmuney Posted July 25, 2007 Share Posted July 25, 2007 If I use query1, the output is fast but skips results. If I use query2, the output is correct but output is very slow in comparison to query1. What modifications can I make to either query to get the correct output and fast? QUERY1 $sql = "select MAX(s1.sih_id),s1.scm_mem_id from scm_invite_history s1,sc_member_images s2 where s1.scm_mem_id=s2.scm_mem_id and s2.sci_main=1 GROUP BY s1.scm_mem_id ORDER BY s1.sih_id DESC LIMIT 0,$l"; QUERY2 $sql = "select MAX(sih_id),scm_mem_id from scm_invite_history WHERE scm_mem_id IN (SELECT scm_mem_id FROM sc_member_images WHERE sci_main=1) GROUP BY scm_mem_id ORDER BY MAX(sih_id) DESC LIMIT 0,$l"; Quote Link to comment Share on other sites More sharing options...
btherl Posted July 26, 2007 Share Posted July 26, 2007 Can you show us the output of each? In the first query I notice your "ORDER BY" clause doesn't makes sense. It should be ordering by max(s1.sih_id), not by s1.sih_id. Quote Link to comment Share on other sites More sharing options...
jcarouth Posted July 26, 2007 Share Posted July 26, 2007 how about posting table structure, example data, and desired results. Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 26, 2007 Share Posted July 26, 2007 kindly post ur database structure and the result u want ... Quote Link to comment Share on other sites More sharing options...
rameshfaj Posted July 26, 2007 Share Posted July 26, 2007 I think ur table structure is some abnormal one.Plz have a post of it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.