<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Amit's Blog...</title>
	<link>http://amit.myktm.com</link>
	<description>On Life, Technology and 'More'...</description>
	<pubDate>Mon, 23 Mar 2009 04:28:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.3</generator>
	<language>en</language>
			<item>
		<title>SQL Concatenate rows from same column</title>
		<link>http://amit.myktm.com/sql-concatenate-rows-from-same-column/</link>
		<comments>http://amit.myktm.com/sql-concatenate-rows-from-same-column/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 20:21:46 +0000</pubDate>
		<dc:creator>Amit Chaudhary</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://amit.myktm.com/sql-concatenate-rows-from-same-column/</guid>
		<description><![CDATA[The other day when I was helping my friend with an assignment I came across a very interesting query. Most of us might have used the SQL Concat function to concatenate from two columns in a row. That is pretty easy for eg.
SELECT CONCAT(firstname, ‘ ‘, secondname) FROM profiles;

The above SQL Statement is very easy [...]]]></description>
			<content:encoded><![CDATA[<p>The other day when I was helping my friend with an assignment I came across a very interesting query. Most of us might have used the SQL Concat function to concatenate from two columns in a row. That is pretty easy for eg.</p>
<p><code>SELECT CONCAT(firstname, ‘ ‘, secondname) FROM profiles;<br />
</code></p>
<p>The above SQL Statement is very easy and self explanatory.</p>
<p>Now, how would you write a query (or queries) where you want to <strong>concatenate elements from the same column from all the rows</strong> that have been selected? For example if you would want a list all the usernames in the table separated by a comma:</p>
<p><code>SET @usernames = “”;<br />
--Initialize the variable usernames with an empty string.<br />
SELECT @usernames := CONCAT(@usernames, “, “, username) FROM profiles;<br />
-- Here all the usernames are concatenated to the usernames variable.<br />
-- This is not our output as this will give us multiple rows, with the last row having all the usernames.<br />
SET @usernames = SUBSTRING(@ids FROM 2);<br />
-- Cleaning up the list by removing the comma at the beginning.<br />
SELECT @usernames;<br />
</code></p>
<p>The above set of queries will get you all the usernames separated by comma.</p>
<p>This also solved one of my other problems that I was not able to solve earlier with mySQL. How would you write a query where you could have a column with Serial Number for the records? If you take a look at the above solution, this is very easy.</p>
<p><code>SET @sno = 0;<br />
SELECT @sno := @sno+1 as SNO, username FROM profiles;<br />
</code></p>
<p>This will give you a list of usernames with Serial Numbers as a separate column.</p>
<p>Hope it was worthwhile reading the above <img src='http://amit.myktm.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://amit.myktm.com/sql-concatenate-rows-from-same-column/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RSA Algorithm Implemented in Java</title>
		<link>http://amit.myktm.com/rsa-algorithm-implemented-in-java/</link>
		<comments>http://amit.myktm.com/rsa-algorithm-implemented-in-java/#comments</comments>
		<pubDate>Wed, 02 May 2007 22:13:53 +0000</pubDate>
		<dc:creator>Amit Chaudhary</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://amit.myktm.com/rsa-algorithm-implemented-in-java/</guid>
		<description><![CDATA[I have my Network Information and Security practical exams on the 4th. I have been trying to implement most of these encryption algorithms on Java. The very nature of the algorithms and being incompetent with Java made it that much more difficult; overflowing, under flowing, data loss and what not!
I also tried to find a [...]]]></description>
			<content:encoded><![CDATA[<p>I have my Network Information and Security practical exams on the 4th. I have been trying to implement most of these encryption algorithms on Java. The very nature of the algorithms and being incompetent with Java made it that much more difficult; overflowing, under flowing, data loss and what not!</p>
<p>I also tried to find a simple implementation of the RSA algorithm across the net but with no success. I finally figured a way out to implement it. </p>
<p>It may not be the most accurate implementation; but good enough if you want to learn how RSA works. </p>
<p>The code follows for those who are interested.</p>
<p> <a href="http://amit.myktm.com/rsa-algorithm-implemented-in-java/#more-77" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://amit.myktm.com/rsa-algorithm-implemented-in-java/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
