<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>SQL</title>
	<atom:link href="http://techenclave.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://techenclave.wordpress.com</link>
	<description>THE SQL Server Blog Spot on the Web</description>
	<lastBuildDate>Mon, 01 Feb 2010 11:05:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='techenclave.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>SQL</title>
		<link>http://techenclave.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://techenclave.wordpress.com/osd.xml" title="SQL" />
	<atom:link rel='hub' href='http://techenclave.wordpress.com/?pushpress=hub'/>
		<item>
		<title>SQL SELECT DISTINCT STATEMENT</title>
		<link>http://techenclave.wordpress.com/2009/10/11/the-sql-select-distinct-statement/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/the-sql-select-distinct-statement/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:43:56 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[pl/sql/queries]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[The SQL SELECT DISTINCT Statement]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=16</guid>
		<description><![CDATA[In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table. The DISTINCT keyword can be used to return only distinct (different) values. SQL select distinct syntax SELECT DISTINCT column_name(s) FROM table_name SELECT DISTINCT Example [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=16&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table.</p>
<p>The DISTINCT keyword can be used to return only distinct (different) values.</p>
<h3>SQL select distinct syntax</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT DISTINCT column_name(s)<br />
FROM table_name</td>
</tr>
</tbody>
</table>
<hr />
<h2>SELECT DISTINCT Example</h2>
<p>The &#8220;Persons&#8221; table:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<p>Now we want to select only the distinct values from the column named &#8220;City&#8221; from the table above.</p>
<p>We use the following SELECT statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT DISTINCT City FROM Persons</td>
</tr>
</tbody>
</table>
<p>The result-set will look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="50%">
<tbody>
<tr>
<th align="left">City</th>
</tr>
<tr>
<td>Sandnes</td>
</tr>
<tr>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=16&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/the-sql-select-distinct-statement/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Where Clause</title>
		<link>http://techenclave.wordpress.com/2009/10/11/sql-word-press/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/sql-word-press/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:42:20 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL WORD PRESS]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=18</guid>
		<description><![CDATA[The WHERE clause is used to extract only those records that fulfill a specified criterion. SQL WHERE Syntax SELECT column_name(s) FROM table_name WHERE column_name operator value WHERE Clause Example The &#8220;Persons&#8221; table: P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=18&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The WHERE clause is used to extract only those records that fulfill a specified criterion.</p>
<h3>SQL WHERE Syntax</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT column_name(s)<br />
FROM table_name<br />
WHERE column_name operator value</td>
</tr>
</tbody>
</table>
<hr />
<h2>WHERE Clause Example</h2>
<p>The &#8220;Persons&#8221; table:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<p>Now we want to select only the persons living in the city &#8220;Sandnes&#8221; from the table above.</p>
<p>We use the following SELECT statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM Persons<br />
WHERE City=&#8217;Sandnes&#8217;</td>
</tr>
</tbody>
</table>
<p>The result-set will look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<hr />
<h2>Quotes Around Text Fields</h2>
<p>SQL uses single quotes around text values (most database systems will also accept double quotes).</p>
<p>Although, numeric values should not be enclosed in quotes.</p>
<p>For text values:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>This is correct:</p>
<p>SELECT * FROM Persons WHERE FirstName=&#8217;Tove&#8217;</p>
<p>This is wrong:</p>
<p>SELECT * FROM Persons WHERE FirstName=Tove</td>
</tr>
</tbody>
</table>
<p>For numeric values:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>This is correct:</p>
<p>SELECT * FROM Persons WHERE Year=1965</p>
<p>This is wrong:</p>
<p>SELECT * FROM Persons WHERE Year=&#8217;1965&#8242;</td>
</tr>
</tbody>
</table>
<hr />
<h2>Operators Allowed in the WHERE Clause</h2>
<p>With the WHERE clause, the following operators can be used:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th valign="top">Operator</th>
<th>Description</th>
</tr>
<tr>
<td valign="top">=</td>
<td>Equal</td>
</tr>
<tr>
<td valign="top">&lt;&gt;</td>
<td>Not equal</td>
</tr>
<tr>
<td valign="top">&gt;</td>
<td>Greater than</td>
</tr>
<tr>
<td valign="top">&lt;</td>
<td>Less than</td>
</tr>
<tr>
<td valign="top">&gt;=</td>
<td>Greater than or equal</td>
</tr>
<tr>
<td valign="top">&lt;=</td>
<td>Less than or equal</td>
</tr>
<tr>
<td valign="top">BETWEEN</td>
<td>Between an inclusive range</td>
</tr>
<tr>
<td valign="top">LIKE</td>
<td>Search for a pattern</td>
</tr>
<tr>
<td valign="top">IN</td>
<td>If you know the exact value you want to return for at least one of the columns</td>
</tr>
</tbody>
</table>
<p><strong>Note:</strong> In some versions of SQL the &lt;&gt; operator may be written as !=</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=18&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/sql-word-press/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL AND &amp; OR OPERATORS</title>
		<link>http://techenclave.wordpress.com/2009/10/11/sql-and-or-operators/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/sql-and-or-operators/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:40:01 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL AND & OR OPERATORS]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=21</guid>
		<description><![CDATA[The AND &#38; OR Operators The AND operator displays a record if both the first condition and the second condition is true. The OR operator displays a record if either the first condition or the second condition is true. AND Operator Example The &#8220;Persons&#8221; table: P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=21&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>The AND &amp; OR Operators</h2>
<p>The AND operator displays a record if both the first condition and the second condition is true.</p>
<p>The OR operator displays a record if either the first condition or the second condition is true.</p>
<hr />
<h2>AND Operator Example</h2>
<p>The &#8220;Persons&#8221; table:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<p>Now we want to select only the persons with the first name equal to &#8220;Tove&#8221; AND the last name equal to &#8220;Svendson&#8221;:</p>
<p>We use the following SELECT statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM Persons<br />
WHERE FirstName=&#8217;Tove&#8217;<br />
AND LastName=&#8217;Svendson&#8217;</td>
</tr>
</tbody>
</table>
<p>The result-set will look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<hr />
<h2>OR Operator Example</h2>
<p>Now we want to select only the persons with the first name equal to &#8220;Tove&#8221; OR the first name equal to &#8220;Ola&#8221;:</p>
<p>We use the following SELECT statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM Persons<br />
WHERE FirstName=&#8217;Tove&#8217;<br />
OR FirstName=&#8217;Ola&#8217;</td>
</tr>
</tbody>
</table>
<p>The result-set will look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<hr />
<h2>Combining AND &amp; OR</h2>
<p>You can also combine AND and OR (use parenthesis to form complex expressions).</p>
<p>Now we want to select only the persons with the last name equal to &#8220;Svendson&#8221;  AND the first name equal to &#8220;Tove&#8221; OR to &#8220;Ola&#8221;:</p>
<p>We use the following SELECT statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM Persons WHERE<br />
LastName=&#8217;Svendson&#8217;<br />
AND (FirstName=&#8217;Tove&#8217; OR FirstName=&#8217;Ola&#8217;)</td>
</tr>
</tbody>
</table>
<p>The result-set will look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=21&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/sql-and-or-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL ORDER BY KEYWORD</title>
		<link>http://techenclave.wordpress.com/2009/10/11/sql-order-by-keyword/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/sql-order-by-keyword/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:39:11 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL ORDER BY KEYWORD]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=22</guid>
		<description><![CDATA[The ORDER BY keyword is used to sort the result-set by a specified column. The ORDER BY keyword sort the records in ascending order by default. If you want to sort the records in a descending order, you can use the DESC keyword. SQL ORDER BY Syntax SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC&#124;DESC [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=22&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The ORDER BY keyword is used to sort the result-set by a specified column.</p>
<p>The ORDER BY keyword sort the records in ascending order by default.</p>
<p>If you want to sort the records in a descending order, you can use the DESC keyword.</p>
<h3>SQL ORDER BY Syntax</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT column_name(s)<br />
FROM table_name<br />
ORDER BY column_name(s) ASC|DESC</td>
</tr>
</tbody>
</table>
<hr />
<h2>ORDER BY Example</h2>
<p>The &#8220;Persons&#8221; table:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Tom</td>
<td>Vingvn 23</td>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<p>Now we want to select all the persons from the table above, however, we want to sort the persons by their last name.</p>
<p>We use the following SELECT statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM Persons<br />
ORDER BY LastName</td>
</tr>
</tbody>
</table>
<p>The result-set will look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Tom</td>
<td>Vingvn 23</td>
<td>Stavanger</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<hr />
<h2>ORDER BY DESC Example</h2>
<p>Now we want to select all the persons from the table above, however, we want to sort the persons descending by their last name.</p>
<p>We use the following SELECT statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM Persons<br />
ORDER BY LastName DESC</td>
</tr>
</tbody>
</table>
<p>The result-set will look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Tom</td>
<td>Vingvn 23</td>
<td>Stavanger</td>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=22&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/sql-order-by-keyword/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL INSERT INTO statement</title>
		<link>http://techenclave.wordpress.com/2009/10/11/sql-insert-into-statement/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/sql-insert-into-statement/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:38:28 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL INSERT INTO statement]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=23</guid>
		<description><![CDATA[The INSERT INTO statement is used to insert a new row in a table. SQL INSERT INTO Syntax It is possible to write the INSERT INTO statement in two forms. The first form doesn&#8217;t specify the column names where the data will be inserted, only their values: INSERT INTO table_name VALUES (value1, value2, value3,&#8230;) The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=23&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The INSERT INTO statement is used to insert a new row in a table.</p>
<h3>SQL INSERT INTO Syntax</h3>
<p>It is possible to write the INSERT INTO statement in two forms.</p>
<p>The first form doesn&#8217;t specify the column names where the data will be inserted, only their values:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>INSERT INTO table_name<br />
VALUES (value1, value2, value3,&#8230;)</td>
</tr>
</tbody>
</table>
<p>The second form specifies both the column names and the values to be inserted:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>INSERT INTO table_name (column1, column2, column3,&#8230;)<br />
VALUES (value1, value2, value3,&#8230;)</td>
</tr>
</tbody>
</table>
<hr />
<h2>SQL INSERT INTO Example</h2>
<p>We have the following &#8220;Persons&#8221; table:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<p>Now we want to insert a new row in the &#8220;Persons&#8221; table.</p>
<p>We use the following SQL statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>INSERT INTO Persons<br />
VALUES (4,&#8217;Nilsen&#8217;, &#8216;Johan&#8217;, &#8216;Bakken 2&#8242;, &#8216;Stavanger&#8217;)</td>
</tr>
</tbody>
</table>
<p>The &#8220;Persons&#8221; table will now look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Johan</td>
<td>Bakken 2</td>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<hr />
<h2>Insert Data Only in Specified Columns</h2>
<p>It is also possible to only add data in specific columns.</p>
<p>The following SQL statement will add a new row, but only add data in the &#8220;P_Id&#8221;, &#8220;LastName&#8221; and the &#8220;FirstName&#8221; columns:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>INSERT INTO Persons (P_Id, LastName, FirstName)<br />
VALUES (5, &#8216;Tjessem&#8217;, &#8216;Jakob&#8217;)</td>
</tr>
</tbody>
</table>
<p>The &#8220;Persons&#8221; table will now look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Johan</td>
<td>Bakken 2</td>
<td>Stavanger</td>
</tr>
<tr>
<td>5</td>
<td>Tjessem</td>
<td>Jakob</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=23&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/sql-insert-into-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL UPDATE STATEMENT</title>
		<link>http://techenclave.wordpress.com/2009/10/11/sql-update-statement/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/sql-update-statement/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:37:28 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL UPDATE STATEMENT]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=24</guid>
		<description><![CDATA[The UPDATE statement is used to update existing records in a table. SQL UPDATE Syntax UPDATE table_name SET column1=value, column2=value2,&#8230; WHERE some_column=some_value Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated! SQL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=24&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The UPDATE statement is used to update existing records in a table.</p>
<h3>SQL UPDATE Syntax</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>UPDATE table_name<br />
SET column1=value, column2=value2,&#8230;<br />
WHERE some_column=some_value</td>
</tr>
</tbody>
</table>
<p><strong>Note:</strong> Notice the WHERE clause in the UPDATE syntax. The WHERE clause  specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated!</p>
<hr />
<h2>SQL UPDATE Example</h2>
<p>The &#8220;Persons&#8221; table:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Johan</td>
<td>Bakken 2</td>
<td>Stavanger</td>
</tr>
<tr>
<td>5</td>
<td>Tjessem</td>
<td>Jakob</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>Now we want to update the person &#8220;Tjessem, Jakob&#8221; in the &#8220;Persons&#8221; table.</p>
<p>We use the following SQL statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>UPDATE Persons<br />
SET Address=&#8217;Nissestien 67&#8242;, City=&#8217;Sandnes&#8217;<br />
WHERE LastName=&#8217;Tjessem&#8217; AND FirstName=&#8217;Jakob&#8217;</td>
</tr>
</tbody>
</table>
<p>The &#8220;Persons&#8221; table will now look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Johan</td>
<td>Bakken 2</td>
<td>Stavanger</td>
</tr>
<tr>
<td>5</td>
<td>Tjessem</td>
<td>Jakob</td>
<td>Nissestien 67</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<hr />
<h2>SQL UPDATE Warning</h2>
<p>Be careful when updating records. If we had omitted the WHERE clause in the example above, like this:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>UPDATE Persons<br />
SET Address=&#8217;Nissestien 67&#8242;, City=&#8217;Sandnes&#8217;</td>
</tr>
</tbody>
</table>
<p>The &#8220;Persons&#8221; table would have looked like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Nissestien 67</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Nissestien 67</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Nissestien 67</td>
<td>Sandnes</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Johan</td>
<td>Nissestien 67</td>
<td>Sandnes</td>
</tr>
<tr>
<td>5</td>
<td>Tjessem</td>
<td>Jakob</td>
<td>Nissestien 67</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=24&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/sql-update-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>
	</item>
		<item>
		<title>THE DELETE STATEMENT</title>
		<link>http://techenclave.wordpress.com/2009/10/11/the-delete-statement/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/the-delete-statement/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:36:37 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[THE DELETE STATEMENT]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=25</guid>
		<description><![CDATA[The DELETE Statement The DELETE statement is used to delete rows in a table. SQL DELETE Syntax DELETE FROM table_name WHERE some_column=some_value Note: Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted! SQL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=25&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>The DELETE Statement</h2>
<p>The DELETE statement is used to delete rows in a table.</p>
<h3>SQL DELETE Syntax</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>DELETE FROM table_name<br />
WHERE some_column=some_value</td>
</tr>
</tbody>
</table>
<p><strong>Note:</strong> Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted!</p>
<hr />
<h2>SQL DELETE Example</h2>
<p>The &#8220;Persons&#8221; table:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Johan</td>
<td>Bakken 2</td>
<td>Stavanger</td>
</tr>
<tr>
<td>5</td>
<td>Tjessem</td>
<td>Jakob</td>
<td>Nissestien 67</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<p>Now we want to delete the person &#8220;Tjessem, Jakob&#8221; in the &#8220;Persons&#8221; table.</p>
<p>We use the following SQL statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>DELETE FROM Persons<br />
WHERE LastName=&#8217;Tjessem&#8217; AND FirstName=&#8217;Jakob&#8217;</td>
</tr>
</tbody>
</table>
<p>The &#8220;Persons&#8221; table will now look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Johan</td>
<td>Bakken 2</td>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<hr />
<h2>Delete All Rows</h2>
<p>It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>DELETE FROM table_name</p>
<p>or</p>
<p>DELETE * FROM table_name</td>
</tr>
</tbody>
</table>
<p><strong>Note:</strong> Be very careful when deleting records. You cannot undo this statement!</p>
<hr />
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=25&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/the-delete-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL EXERCISES</title>
		<link>http://techenclave.wordpress.com/2009/10/11/sql-exercises/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/sql-exercises/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:34:19 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL EXERCISES]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=26</guid>
		<description><![CDATA[Test your SQL Skills On this page you can test your SQL skills. We will use the Customers table in the Northwind database: CompanyName ContactName Address City Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå Centro comercial Moctezuma Francisco Chang Sierras de Granada 9993 México D.F. Ernst Handel [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=26&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Test your SQL Skills</h2>
<p>On this page you can test your SQL skills.</p>
<p>We will use the <strong>Customers</strong> table in the Northwind database:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">CompanyName</th>
<th align="left">ContactName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td valign="top">Alfreds Futterkiste</td>
<td valign="top">Maria Anders</td>
<td valign="top">Obere Str. 57</td>
<td valign="top">Berlin</td>
</tr>
<tr>
<td valign="top">Berglunds snabbköp</td>
<td valign="top">Christina Berglund</td>
<td valign="top">Berguvsvägen 8</td>
<td valign="top">Luleå</td>
</tr>
<tr>
<td valign="top">Centro comercial Moctezuma</td>
<td valign="top">Francisco Chang</td>
<td valign="top">Sierras de Granada 9993</td>
<td valign="top">México D.F.</td>
</tr>
<tr>
<td valign="top">Ernst Handel</td>
<td valign="top">Roland Mendel</td>
<td valign="top">Kirchgasse 6</td>
<td valign="top">Graz</td>
</tr>
<tr>
<td valign="top">FISSA Fabrica Inter. Salchichas S.A.</td>
<td valign="top">Diego Roel</td>
<td valign="top">C/ Moralzarzal, 86</td>
<td valign="top">Madrid</td>
</tr>
<tr>
<td valign="top">Galería del gastrónomo</td>
<td valign="top">Eduardo Saavedra</td>
<td valign="top">Rambla de Cataluña, 23</td>
<td valign="top">Barcelona</td>
</tr>
<tr>
<td valign="top">Island Trading</td>
<td valign="top">Helen Bennett</td>
<td valign="top">Garden House Crowther Way</td>
<td valign="top">Cowes</td>
</tr>
<tr>
<td valign="top">Königlich Essen</td>
<td valign="top">Philip Cramer</td>
<td valign="top">Maubelstr. 90</td>
<td valign="top">Brandenburg</td>
</tr>
<tr>
<td valign="top">Laughing Bacchus Wine Cellars</td>
<td valign="top">Yoshi Tannamuri</td>
<td valign="top">1900 Oak St.</td>
<td valign="top">Vancouver</td>
</tr>
<tr>
<td valign="top">Magazzini Alimentari Riuniti</td>
<td valign="top">Giovanni Rovelli</td>
<td valign="top">Via Ludovico il Moro 22</td>
<td valign="top">Bergamo</td>
</tr>
<tr>
<td valign="top">North/South</td>
<td valign="top">Simon Crowther</td>
<td valign="top">South House 300 Queensbridge</td>
<td valign="top">London</td>
</tr>
<tr>
<td valign="top">Paris spécialités</td>
<td valign="top">Marie Bertrand</td>
<td valign="top">265, boulevard Charonne</td>
<td valign="top">Paris</td>
</tr>
<tr>
<td valign="top">Rattlesnake Canyon Grocery</td>
<td valign="top">Paula Wilson</td>
<td valign="top">2817 Milton Dr.</td>
<td valign="top">Albuquerque</td>
</tr>
<tr>
<td valign="top">Simons bistro</td>
<td valign="top">Jytte Petersen</td>
<td valign="top">Vinbæltet 34</td>
<td valign="top">København</td>
</tr>
<tr>
<td valign="top">The Big Cheese</td>
<td valign="top">Liz Nixon</td>
<td valign="top">89 Jefferson Way Suite 2</td>
<td valign="top">Portland</td>
</tr>
<tr>
<td valign="top">Vaffeljernet</td>
<td valign="top">Palle Ibsen</td>
<td valign="top">Smagsløget 45</td>
<td valign="top">Århus</td>
</tr>
<tr>
<td valign="top">Wolski Zajazd</td>
<td valign="top">Zbyszek Piestrzeniewicz</td>
<td valign="top">ul. Filtrowa 68</td>
<td valign="top">Warszawa</td>
</tr>
</tbody>
</table>
<p>To preserve space, the table above is a subset of the Customers table used in the example below.</p>
<hr />
<h2>Try it Yourself</h2>
<p>To see how SQL works, you can copy the SQL statements below and paste them into the textarea, or you can make your own SQL statements.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM customers</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT CompanyName, ContactName FROM customers</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM customers WHERE companyname LIKE &#8216;a%&#8217;</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT CompanyName, ContactName<br />
FROM customers<br />
WHERE CompanyName &gt; &#8216;a&#8217;</td>
</tr>
</tbody>
</table>
<p><img src="http://ww.w3schools.com/sql/lamp.gif" border="0" alt="" width="15" height="15" /> When using SQL on text data, &#8220;alfred&#8221; is greater than &#8220;a&#8221; (like in a dictionary).</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT CompanyName, ContactName<br />
FROM customers<br />
WHERE CompanyName &gt; &#8216;g&#8217;<br />
AND ContactName &gt; &#8216;g&#8217;</td>
</tr>
</tbody>
</table>
<p>SELECT * FROM customers</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=26&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/sql-exercises/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>

		<media:content url="http://ww.w3schools.com/sql/lamp.gif" medium="image" />
	</item>
		<item>
		<title>SQL TRY IT</title>
		<link>http://techenclave.wordpress.com/2009/10/11/sql-try-it/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/sql-try-it/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:33:27 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL TRY IT]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=27</guid>
		<description><![CDATA[Test your SQL Skills On this page you can test your SQL skills. We will use the Customers table in the Northwind database: CompanyName ContactName Address City Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå Centro comercial Moctezuma Francisco Chang Sierras de Granada 9993 México D.F. Ernst Handel [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=27&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Test your SQL Skills</h2>
<p>On this page you can test your SQL skills.</p>
<p>We will use the <strong>Customers</strong> table in the Northwind database:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">CompanyName</th>
<th align="left">ContactName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td valign="top">Alfreds Futterkiste</td>
<td valign="top">Maria Anders</td>
<td valign="top">Obere Str. 57</td>
<td valign="top">Berlin</td>
</tr>
<tr>
<td valign="top">Berglunds snabbköp</td>
<td valign="top">Christina Berglund</td>
<td valign="top">Berguvsvägen 8</td>
<td valign="top">Luleå</td>
</tr>
<tr>
<td valign="top">Centro comercial Moctezuma</td>
<td valign="top">Francisco Chang</td>
<td valign="top">Sierras de Granada 9993</td>
<td valign="top">México D.F.</td>
</tr>
<tr>
<td valign="top">Ernst Handel</td>
<td valign="top">Roland Mendel</td>
<td valign="top">Kirchgasse 6</td>
<td valign="top">Graz</td>
</tr>
<tr>
<td valign="top">FISSA Fabrica Inter. Salchichas S.A.</td>
<td valign="top">Diego Roel</td>
<td valign="top">C/ Moralzarzal, 86</td>
<td valign="top">Madrid</td>
</tr>
<tr>
<td valign="top">Galería del gastrónomo</td>
<td valign="top">Eduardo Saavedra</td>
<td valign="top">Rambla de Cataluña, 23</td>
<td valign="top">Barcelona</td>
</tr>
<tr>
<td valign="top">Island Trading</td>
<td valign="top">Helen Bennett</td>
<td valign="top">Garden House Crowther Way</td>
<td valign="top">Cowes</td>
</tr>
<tr>
<td valign="top">Königlich Essen</td>
<td valign="top">Philip Cramer</td>
<td valign="top">Maubelstr. 90</td>
<td valign="top">Brandenburg</td>
</tr>
<tr>
<td valign="top">Laughing Bacchus Wine Cellars</td>
<td valign="top">Yoshi Tannamuri</td>
<td valign="top">1900 Oak St.</td>
<td valign="top">Vancouver</td>
</tr>
<tr>
<td valign="top">Magazzini Alimentari Riuniti</td>
<td valign="top">Giovanni Rovelli</td>
<td valign="top">Via Ludovico il Moro 22</td>
<td valign="top">Bergamo</td>
</tr>
<tr>
<td valign="top">North/South</td>
<td valign="top">Simon Crowther</td>
<td valign="top">South House 300 Queensbridge</td>
<td valign="top">London</td>
</tr>
<tr>
<td valign="top">Paris spécialités</td>
<td valign="top">Marie Bertrand</td>
<td valign="top">265, boulevard Charonne</td>
<td valign="top">Paris</td>
</tr>
<tr>
<td valign="top">Rattlesnake Canyon Grocery</td>
<td valign="top">Paula Wilson</td>
<td valign="top">2817 Milton Dr.</td>
<td valign="top">Albuquerque</td>
</tr>
<tr>
<td valign="top">Simons bistro</td>
<td valign="top">Jytte Petersen</td>
<td valign="top">Vinbæltet 34</td>
<td valign="top">København</td>
</tr>
<tr>
<td valign="top">The Big Cheese</td>
<td valign="top">Liz Nixon</td>
<td valign="top">89 Jefferson Way Suite 2</td>
<td valign="top">Portland</td>
</tr>
<tr>
<td valign="top">Vaffeljernet</td>
<td valign="top">Palle Ibsen</td>
<td valign="top">Smagsløget 45</td>
<td valign="top">Århus</td>
</tr>
<tr>
<td valign="top">Wolski Zajazd</td>
<td valign="top">Zbyszek Piestrzeniewicz</td>
<td valign="top">ul. Filtrowa 68</td>
<td valign="top">Warszawa</td>
</tr>
</tbody>
</table>
<p>To preserve space, the table above is a subset of the Customers table used in the example below.</p>
<hr />
<h2>Try it Yourself</h2>
<p>To see how SQL works, you can copy the SQL statements below and paste them into the textarea, or you can make your own SQL statements.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM customers</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT CompanyName, ContactName FROM customers</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT * FROM customers WHERE companyname LIKE &#8216;a%&#8217;</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT CompanyName, ContactName<br />
FROM customers<br />
WHERE CompanyName &gt; &#8216;a&#8217;</td>
</tr>
</tbody>
</table>
<p><img src="http://ww.w3schools.com/sql/lamp.gif" border="0" alt="" width="15" height="15" /> When using SQL on text data, &#8220;alfred&#8221; is greater than &#8220;a&#8221; (like in a dictionary).</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT CompanyName, ContactName<br />
FROM customers<br />
WHERE CompanyName &gt; &#8216;g&#8217;<br />
AND ContactName &gt; &#8216;g&#8217;</td>
</tr>
</tbody>
</table>
<p>SELECT * FROM customers</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=27&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/sql-try-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>

		<media:content url="http://ww.w3schools.com/sql/lamp.gif" medium="image" />
	</item>
		<item>
		<title>SQL TOP</title>
		<link>http://techenclave.wordpress.com/2009/10/11/sql-top/</link>
		<comments>http://techenclave.wordpress.com/2009/10/11/sql-top/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 17:32:35 +0000</pubDate>
		<dc:creator>Deepanshu Mehta</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[SQL TOP]]></category>

		<guid isPermaLink="false">http://techenclave.wordpress.com/?p=28</guid>
		<description><![CDATA[The TOP Clause The TOP clause is used to specify the number of records to return. The TOP clause can be very useful on large tables with thousands of records. Returning a large number of records can impact on performance. Note: Not all database systems support the TOP clause. SQL Server Syntax SELECT TOP number&#124;percent [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=28&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>The TOP Clause</h2>
<p>The TOP clause is used to specify the number of records to return.</p>
<p>The TOP clause can be very useful on large tables with thousands of records. Returning a large number of records can impact on performance.</p>
<p><strong>Note:</strong> Not all database systems support the TOP clause.</p>
<h3>SQL Server Syntax</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT TOP number|percent column_name(s)<br />
FROM table_name</td>
</tr>
</tbody>
</table>
<hr />
<h2>SQL SELECT TOP Equivalent in MySQL and Oracle</h2>
<h3>MySQL Syntax</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT column_name(s)<br />
FROM table_name<br />
LIMIT number</td>
</tr>
</tbody>
</table>
<h3>Example</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT *<br />
FROM Persons<br />
LIMIT 5</td>
</tr>
</tbody>
</table>
<h3>Oracle Syntax</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT column_name(s)<br />
FROM table_name<br />
WHERE ROWNUM &lt;= number</td>
</tr>
</tbody>
</table>
<h3>Example</h3>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT *<br />
FROM Persons<br />
WHERE ROWNUM &lt;=5</td>
</tr>
</tbody>
</table>
<hr />
<h2>SQL TOP Example</h2>
<p>The &#8220;Persons&#8221; table:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Tom</td>
<td>Vingvn 23</td>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<p>Now we want to select only the two first records in the table above.</p>
<p>We use the following SELECT statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT TOP 2 * FROM Persons</td>
</tr>
</tbody>
</table>
<p>The result-set will look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<hr />
<h2>SQL TOP PERCENT Example</h2>
<p>The &#8220;Persons&#8221; table:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>3</td>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>4</td>
<td>Nilsen</td>
<td>Tom</td>
<td>Vingvn 23</td>
<td>Stavanger</td>
</tr>
</tbody>
</table>
<p>Now we want to select only 50% of the records in the table above.</p>
<p>We use the following SELECT statement:</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>SELECT TOP 50 PERCENT * FROM Persons</td>
</tr>
</tbody>
</table>
<p>The result-set will look like this:</p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<th align="left">P_Id</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">Address</th>
<th align="left">City</th>
</tr>
<tr>
<td>1</td>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>2</td>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/techenclave.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/techenclave.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/techenclave.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/techenclave.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/techenclave.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/techenclave.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/techenclave.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/techenclave.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/techenclave.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/techenclave.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/techenclave.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/techenclave.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/techenclave.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/techenclave.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=techenclave.wordpress.com&amp;blog=9348608&amp;post=28&amp;subd=techenclave&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://techenclave.wordpress.com/2009/10/11/sql-top/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c72cc40599c4d2b243682d09ab5de52?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">exoticexpedition</media:title>
		</media:content>
	</item>
	</channel>
</rss>
