View Single Post
Old 08-07-2011, 02:33 PM  
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Quote:
Originally Posted by cooldude7 View Post
this is the original query and it throws whole data,

$result = mysql_query("SELECT content.*, content_views.views AS views FROM content, content_views WHERE content_views.content = content.record_num AND content.approved = 2 AND content.enabled = 1 ORDER BY encoded_date");


so i want to limit the values from column record_num from say 1 to 20k.
record_num is kind of index so i can limit the output .

how do i do this ?

thanks for your time.
LIMIT is used to grab "pages" of data..

SELECT content.*, content_views.views AS views FROM content, content_views WHERE content_views.content = content.record_num AND content.approved = 2 AND content.enabled = 1 ORDER BY encoded_date LIMIT 0,1000

LIMIT 0,1000 - get the first 1000 entries
LIMIT 1000,1000 - get the 2nd set of 1000 entries
LIMIT 2000,1000 - get the 3rd set of 1000 entries

If you don't use LIMIT, then really, you're ORDER BY has no meaning.
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote