mysql - Can LIMIT alter results of queries? -


i have database twitter have users , msgs , users can subscribe , block other users. need show msgs subscribed users not blocked, have query this:

select distinct m.mid, m.author, m.content msgs m, subs s, blocks b s.uid = 3 , s.sub_uid = m.author , b.uid = 3 , m.author not in     (select b2.bl_uid blocks b2 b2.uid = 3) order m.mid desc limit 30; 

without 'limit 30' query works fine, gives me correct rows, 'limit 30' have wrong results, because query gives me correct rows plus rows belong users subscribed , blocked. how can 'limit' alter result?

edit: user has uid = 3 has 2 users subscribed, users 5 , 6, , user 6 blocked, need show msgs user 5, 'limit 30' msgs user 6 returned.

just total guess here, find myself wondering if limit clause being applied subquery well, blocking first 30 authors in blocks table.

try refactoring query avoid using subquery.

as bonus, you'll eliminate performance problems inherent in subquery implementation in mysql when start add more little data.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -