<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to number rows in MySQL</title>
	<atom:link href="http://www.xaprb.com/blog/2006/12/02/how-to-number-rows-in-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2006/12/02/how-to-number-rows-in-mysql/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:56:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: John Lynn</title>
		<link>http://www.xaprb.com/blog/2006/12/02/how-to-number-rows-in-mysql/#comment-19639</link>
		<dc:creator>John Lynn</dc:creator>
		<pubDate>Sat, 17 Sep 2011 21:58:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=265#comment-19639</guid>
		<description>Great tip! It doesn&#039;t work if &quot;fruits&quot; (the table you&#039;re selecting from) is a view, it seems. Using MySQL 5.5 

Thanks...</description>
		<content:encoded><![CDATA[<p>Great tip! It doesn&#8217;t work if &#8220;fruits&#8221; (the table you&#8217;re selecting from) is a view, it seems. Using MySQL 5.5 </p>
<p>Thanks&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ozlem</title>
		<link>http://www.xaprb.com/blog/2006/12/02/how-to-number-rows-in-mysql/#comment-18934</link>
		<dc:creator>Ozlem</dc:creator>
		<pubDate>Mon, 22 Nov 2010 22:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=265#comment-18934</guid>
		<description>Hi, this is a great solution however it does not work from php. I mean when I run the query through php it does not gather any result. it does not recognize first 2 lines of code, set functions...Any suggestion is appreciated.?Thanks...Ozlem.

set @countT = 0;
set @rowCount = 0;

SELECT MQ2.period_id, MQ2.lt_id, MQ2.period_name, MQ2.min_stay, MQ2.fromDate, MQ2.toDate, MQ2.nightly_rate, MQ2.periodDays, 
MQ2.totalDays, MQ2.fixed_rate,  @countT as periodDaysTotal, @rowCount as rowsTotal , 

IF ((@rowCount=1),
	
			IF((MQ2.periodDays &lt;= (SELECT MAX(night_of_stay) FROM lt_hrules WHERE period_id=MQ2.period_id AND lt_id=MQ2.lt_id)),
		
				IF(MQ2.periodDays IN (SELECT night_of_stay FROM lt_hrules WHERE period_id=MQ2.period_id AND lt_id=MQ2.lt_id),
					(SELECT fixed_rate FROM lt_hrules WHERE period_id = MQ2.period_id AND lt_id = MQ2.lt_id AND night_of_stay = MQ2.periodDays ),
					(SELECT fixed_rate FROM lt_hrules WHERE period_id = MQ2.period_id AND lt_id =  MQ2.lt_id AND night_of_stay = 
							(SELECT MAX(night_of_stay) from lt_hrules WHERE period_id = MQ2.period_id AND lt_id =  MQ2.lt_id))
				),
		
				(MQ2.nightly_rate * MQ2.periodDays)) ,
				
		(MQ2.nightly_rate * MQ2.periodDays) 
	) as price
FROM</description>
		<content:encoded><![CDATA[<p>Hi, this is a great solution however it does not work from php. I mean when I run the query through php it does not gather any result. it does not recognize first 2 lines of code, set functions&#8230;Any suggestion is appreciated.?Thanks&#8230;Ozlem.</p>
<p>set @countT = 0;<br />
set @rowCount = 0;</p>
<p>SELECT MQ2.period_id, MQ2.lt_id, MQ2.period_name, MQ2.min_stay, MQ2.fromDate, MQ2.toDate, MQ2.nightly_rate, MQ2.periodDays,<br />
MQ2.totalDays, MQ2.fixed_rate,  @countT as periodDaysTotal, @rowCount as rowsTotal , </p>
<p>IF ((@rowCount=1),</p>
<p>			IF((MQ2.periodDays &lt;= (SELECT MAX(night_of_stay) FROM lt_hrules WHERE period_id=MQ2.period_id AND lt_id=MQ2.lt_id)),</p>
<p>				IF(MQ2.periodDays IN (SELECT night_of_stay FROM lt_hrules WHERE period_id=MQ2.period_id AND lt_id=MQ2.lt_id),<br />
					(SELECT fixed_rate FROM lt_hrules WHERE period_id = MQ2.period_id AND lt_id = MQ2.lt_id AND night_of_stay = MQ2.periodDays ),<br />
					(SELECT fixed_rate FROM lt_hrules WHERE period_id = MQ2.period_id AND lt_id =  MQ2.lt_id AND night_of_stay =<br />
							(SELECT MAX(night_of_stay) from lt_hrules WHERE period_id = MQ2.period_id AND lt_id =  MQ2.lt_id))<br />
				),</p>
<p>				(MQ2.nightly_rate * MQ2.periodDays)) ,</p>
<p>		(MQ2.nightly_rate * MQ2.periodDays)<br />
	) as price<br />
FROM</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zilus</title>
		<link>http://www.xaprb.com/blog/2006/12/02/how-to-number-rows-in-mysql/#comment-18489</link>
		<dc:creator>Zilus</dc:creator>
		<pubDate>Thu, 08 Jul 2010 22:26:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=265#comment-18489</guid>
		<description>Awsome! I use this in a Query to order my results, sort of &quot;x / x/&quot; I mean, like $num / $total

I&#039;ll post my code and give you credits!

Thanks!</description>
		<content:encoded><![CDATA[<p>Awsome! I use this in a Query to order my results, sort of &#8220;x / x/&#8221; I mean, like $num / $total</p>
<p>I&#8217;ll post my code and give you credits!</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nico</title>
		<link>http://www.xaprb.com/blog/2006/12/02/how-to-number-rows-in-mysql/#comment-18479</link>
		<dc:creator>Nico</dc:creator>
		<pubDate>Tue, 06 Jul 2010 10:46:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=265#comment-18479</guid>
		<description>Thank you for sharing! 

The use of an order by clause does mix up the row numbers for me. In case you need an order by you can use a subquery for the ordering and apply the order number in the outer select...</description>
		<content:encoded><![CDATA[<p>Thank you for sharing! </p>
<p>The use of an order by clause does mix up the row numbers for me. In case you need an order by you can use a subquery for the ordering and apply the order number in the outer select&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ä¹Ÿè°ˆMySQLä¸­å®žçŽ°ROWNUM - è½¶ä¾ çš„ç½‘ä¸Šå°çª</title>
		<link>http://www.xaprb.com/blog/2006/12/02/how-to-number-rows-in-mysql/#comment-16611</link>
		<dc:creator>ä¹Ÿè°ˆMySQLä¸­å®žçŽ°ROWNUM - è½¶ä¾ çš„ç½‘ä¸Šå°çª</dc:creator>
		<pubDate>Mon, 29 Jun 2009 02:15:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=265#comment-16611</guid>
		<description>[...] How to number rows in MySQL [...]</description>
		<content:encoded><![CDATA[<p>[...] How to number rows in MySQL [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

