<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Nested set level via SQL</title>
	<link>http://www.trirand.com/blog/?page_id=393/treegrid/nested-set-level-via-sql</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/treegrid/nested-set-level-via-sql/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Das123 on Nested set level via SQL</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/nested-set-level-via-sql#p8138</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/nested-set-level-via-sql#p8138</guid>
        	        	<description><![CDATA[<p>Many times the nested set model doesn&#39;t have a &#39;level&#39; field. This can be calculated from just the &#39;lft&#39; and &#39;rgt&#39; fields although it does add overhead to the mySQL server. Hope this helps someone else. 🙂</p>
<p>This has been adapted from a technique used by Joe Celco and the amazing work he has done with nested sets...</p>
<p>$SQL = sprintf("<br />SELECT t1.id AS id, t1.title AS title, t1.lft AS lft, t1.rgt AS rgt, COUNT(t2.id) AS level <br />FROM my_table AS t1, my_table AS t2 <br />WHERE (t1.lft BETWEEN t2.lft AND t2.rgt)<br />AND (t1.lft &#62; %s AND t1.rgt &#60; %s )<br />GROUP BY t1.id<br />HAVING (COUNT(t2.id)= %s ) <br />ORDER BY t1.lft;"<br />, $n_lft<br />, $n_rgt<br />, $n_lvl );&#160;&#160;&#160; &#160;&#160;&#160; </p>
<blockquote>
</blockquote>
]]></description>
        	        	<pubDate>Wed, 29 Jul 2009 16:01:32 +0300</pubDate>
        </item>
</channel>
</rss>