<?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: Displaying row number (rownum) in MySQL</title>
	<atom:link href="http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/</link>
	<description>My name is Jimmy, and this is my story... ;)</description>
	<lastBuildDate>Mon, 06 Feb 2012 04:43:45 +0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ashok sharma</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-2/#comment-698</link>
		<dc:creator>Ashok sharma</dc:creator>
		<pubDate>Wed, 11 Jan 2012 13:22:20 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-698</guid>
		<description>I want to display a table of various datas including a column of s.no. which should be continuous even if removed any data from the table.
Can you please tell me or this code will work for that?</description>
		<content:encoded><![CDATA[<p>I want to display a table of various datas including a column of s.no. which should be continuous even if removed any data from the table.<br />
Can you please tell me or this code will work for that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Code Example</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-1/#comment-695</link>
		<dc:creator>Code Example</dc:creator>
		<pubDate>Sat, 24 Dec 2011 08:47:29 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-695</guid>
		<description>Smart solution!! Thanks Jim.

When I delete a row from a table then auto increment just missed the identity numbers. but this example save lots of time.

Your reply with the Tom&#039;s message also very helpful.

go ahead..</description>
		<content:encoded><![CDATA[<p>Smart solution!! Thanks Jim.</p>
<p>When I delete a row from a table then auto increment just missed the identity numbers. but this example save lots of time.</p>
<p>Your reply with the Tom&#8217;s message also very helpful.</p>
<p>go ahead..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed F</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-1/#comment-694</link>
		<dc:creator>Ed F</dc:creator>
		<pubDate>Sat, 24 Dec 2011 02:29:41 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-694</guid>
		<description>@Jimmy - I was excited to find this solution while trying to convert a MSSQL query using row_number() to MYSQL. Your solution did not work at first because my query uses INNER JOINS, but your response to Jim Zak on Mar 2,&#039;10 supplied the answer. I have no idea why it works, but it does. Guess it&#039;s time to do some research.

THANKS - You have been a BIG help!

Ed</description>
		<content:encoded><![CDATA[<p>@Jimmy &#8211; I was excited to find this solution while trying to convert a MSSQL query using row_number() to MYSQL. Your solution did not work at first because my query uses INNER JOINS, but your response to Jim Zak on Mar 2,&#8217;10 supplied the answer. I have no idea why it works, but it does. Guess it&#8217;s time to do some research.</p>
<p>THANKS &#8211; You have been a BIG help!</p>
<p>Ed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimmy</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-1/#comment-634</link>
		<dc:creator>jimmy</dc:creator>
		<pubDate>Fri, 14 Oct 2011 17:12:10 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-634</guid>
		<description>@Annete: do you mean crystal report?
I&#039;m not really familiar with crystal report, if you can explain the error message in more detail maybe I can give you a hint</description>
		<content:encoded><![CDATA[<p>@Annete: do you mean crystal report?<br />
I&#8217;m not really familiar with crystal report, if you can explain the error message in more detail maybe I can give you a hint</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Annette Bithell</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-1/#comment-632</link>
		<dc:creator>Annette Bithell</dc:creator>
		<pubDate>Tue, 11 Oct 2011 18:57:34 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-632</guid>
		<description>Hello,

I&#039;m trying to use this for a crystal command. But getting an error saying incorrect syntax for version. This is my attempt....can you help??

Select @rownum:=@rownum+1 ‘ranknum’, cust_name,  count(distinct callref) as rank from opencall,(SELECT @rownum:=0) where logdate like &#039;%/08/2011%&#039; 
and companyname=&quot;McDonald&#039;s Nederland&quot; group by cust_name order by rank desc

Thanks in advance
Annette</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>I&#8217;m trying to use this for a crystal command. But getting an error saying incorrect syntax for version. This is my attempt&#8230;.can you help??</p>
<p>Select @rownum:=@rownum+1 ‘ranknum’, cust_name,  count(distinct callref) as rank from opencall,(SELECT @rownum:=0) where logdate like &#8216;%/08/2011%&#8217;<br />
and companyname=&#8221;McDonald&#8217;s Nederland&#8221; group by cust_name order by rank desc</p>
<p>Thanks in advance<br />
Annette</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimmy</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-1/#comment-573</link>
		<dc:creator>jimmy</dc:creator>
		<pubDate>Thu, 25 Aug 2011 07:24:57 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-573</guid>
		<description>@Airforce:

I only notice the sql is wrong inn the FROM, the (SELECT @rownum:=0) r shouldn&#039;t be joined. It should be :
 FROM
  (SELECT @rownum:=0) r,
  contest as g
  LEFT JOIN
  vote as v
  ON
    g.id = v.contest_id</description>
		<content:encoded><![CDATA[<p>@Airforce:</p>
<p>I only notice the sql is wrong inn the FROM, the (SELECT @rownum:=0) r shouldn&#8217;t be joined. It should be :<br />
 FROM<br />
  (SELECT @rownum:=0) r,<br />
  contest as g<br />
  LEFT JOIN<br />
  vote as v<br />
  ON<br />
    g.id = v.contest_id</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Airforce</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-1/#comment-562</link>
		<dc:creator>Airforce</dc:creator>
		<pubDate>Tue, 23 Aug 2011 03:25:10 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-562</guid>
		<description>Hi everybody. I got a problem here. I want to output the number of ranking... but the code below here which top5 will take the same number from contest id. Hope you can help me.

SELECT
		    @rownum:=@rownum+1 top5
			,g.id
			,g.team
			,v.image
			,v.vote
		FROM
			contest as g
			,(SELECT @rownum:=0) r
		LEFT JOIN
			vote as v
		ON
			g.id = v.contest_id
		WHERE
			g.ranking_id = {$ranking_id}  
			AND v.variation_no = 1
			AND g.flg = 1
		ORDER BY
		    v.vote DESC
		LIMIT 
		    5</description>
		<content:encoded><![CDATA[<p>Hi everybody. I got a problem here. I want to output the number of ranking&#8230; but the code below here which top5 will take the same number from contest id. Hope you can help me.</p>
<p>SELECT<br />
		    @rownum:=@rownum+1 top5<br />
			,g.id<br />
			,g.team<br />
			,v.image<br />
			,v.vote<br />
		FROM<br />
			contest as g<br />
			,(SELECT @rownum:=0) r<br />
		LEFT JOIN<br />
			vote as v<br />
		ON<br />
			g.id = v.contest_id<br />
		WHERE<br />
			g.ranking_id = {$ranking_id}<br />
			AND v.variation_no = 1<br />
			AND g.flg = 1<br />
		ORDER BY<br />
		    v.vote DESC<br />
		LIMIT<br />
		    5</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sbeex</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-1/#comment-477</link>
		<dc:creator>sbeex</dc:creator>
		<pubDate>Sun, 03 Jul 2011 07:30:46 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-477</guid>
		<description>Thank you men ! It works very good now ! I was looking for this problem since 2 hours but without you... i would need 1 day maybe ! Thank you !</description>
		<content:encoded><![CDATA[<p>Thank you men ! It works very good now ! I was looking for this problem since 2 hours but without you&#8230; i would need 1 day maybe ! Thank you !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DKATyler</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-1/#comment-392</link>
		<dc:creator>DKATyler</dc:creator>
		<pubDate>Thu, 09 Jun 2011 18:53:21 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-392</guid>
		<description>Thanks!
Needed it to append commas to all rows except the last for something I was working on:

SELECT CONCAT(character,
	      IF(@rownum=rowqty.limit,&#039;&#039;,&#039;,&#039;)
             )
  FROM sandbox,
       (SELECT @rownum:=0) r,
       (SELECT COUNT(*) AS &#039;limit&#039;
          FROM sandbox) as rowqty
 WHERE @rownum:=@rownum+1;</description>
		<content:encoded><![CDATA[<p>Thanks!<br />
Needed it to append commas to all rows except the last for something I was working on:</p>
<p>SELECT CONCAT(character,<br />
	      IF(@rownum=rowqty.limit,&#8221;,&#8217;,')<br />
             )<br />
  FROM sandbox,<br />
       (SELECT @rownum:=0) r,<br />
       (SELECT COUNT(*) AS &#8216;limit&#8217;<br />
          FROM sandbox) as rowqty<br />
 WHERE @rownum:=@rownum+1;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimmy</title>
		<link>http://jimmod.com/blog/2008/09/displaying-row-number-rownum-in-mysql/comment-page-1/#comment-388</link>
		<dc:creator>jimmy</dc:creator>
		<pubDate>Wed, 08 Jun 2011 15:26:51 +0000</pubDate>
		<guid isPermaLink="false">http://jimlife.wordpress.com/2008/09/09/displaying-row-number-rownum-in-mysql/#comment-388</guid>
		<description>@Justin:
It possible with this query (still a bit mess):

select @rownum:=@rownum+1 rank, IF(@score=p.score, @rownum2, @rownum2:=@rownum2+1) rank2, p.*, (@score:=p.score) dummy from player p, (SELECT @rownum:=0) x, (SELECT @rownum2:=0) c, (SELECT @score:=0) r order by score desc limit 10

rank2 will display the ranking you want (no increment on same score).

You should also need to check stored procedure solution which may more appropriate for this case.</description>
		<content:encoded><![CDATA[<p>@Justin:<br />
It possible with this query (still a bit mess):</p>
<p>select @rownum:=@rownum+1 rank, IF(@score=p.score, @rownum2, @rownum2:=@rownum2+1) rank2, p.*, (@score:=p.score) dummy from player p, (SELECT @rownum:=0) x, (SELECT @rownum2:=0) c, (SELECT @score:=0) r order by score desc limit 10</p>
<p>rank2 will display the ranking you want (no increment on same score).</p>
<p>You should also need to check stored procedure solution which may more appropriate for this case.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

