MSSQL get data from table with limit property

MSSQL not supporting LIMIT property, we can use this for 

$query1=”WITH OrderedOrders AS
(SELECT top 100 c.id as blg_id,c.title as post_title,c.introtext as post_content,c.created_by,c.publish_up as post_date,ROW_NUMBER() OVER (ORDER BY c.id) AS ‘RowNumber’ FROM jos_content as c INNER JOIN jos_categories as d on c.catid=d.id where d.parent_id=89 AND c.state=1 ORDER BY c.id DESC)
SELECT * FROM OrderedOrders WHERE RowNumber BETWEEN 50 AND 100;”;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s