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;”;

joomla 2.5 get user name from users table

get user name from jos_users table of joomla 2.5 

 

$query = $db->getQuery(true);
$query->select(‘TOP ‘.$no_top_row.’ c.id as blg_id,c.title as post_title,c.introtext as post_content,c.created_by,c.publish_up as post_date’);
$query->from(‘#__content as c’);
$query->innerJoin(‘#__categories as d on c.catid=d.id’);
$query->where(‘d.parent_id=89 AND c.state=1’);
$query->order(‘c.id DESC’);
$db->setQuery($query,0);
$result_top = $db->loadObjectList();

 

foreach ($result_top as $results){

//$author_names =& JFactory::getUser($results->created_by);
$author_names->name

}