<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1039465040462573013</id><updated>2024-10-04T19:08:27.723-07:00</updated><category term="SQL"/><category term="simple"/><title type='text'>SQLTutorials</title><subtitle type='html'>wlanguages.co.cc HTML ,XHTML Tutorials ,Java Tutorials&#xa;SQL Tutorials ,JavaScript Tutorials ,CSS Tutorials&#xa; ,PHP Tutorials ,ASP.Net Tutorials ,MY SQL Tutorials ,VB.Net Tutorials ,C/C++ Tutorials ,Learn Ruby ,Learn Ruby on Rails ,Ruby on Rails-2.1 ,Learn Python ,Learn Python/DB ,Learn Python/CGI ,Learn Python/XML</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>105</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-7080893226440131058</id><published>2010-09-01T03:47:00.001-07:00</published><updated>2011-04-10T04:39:52.254-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 19px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;What is SQL?&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;&lt;li&gt;SQL stands for Structured Query Language&lt;/li&gt;
&lt;li&gt;SQL lets you access and manipulate databases&lt;/li&gt;
&lt;li&gt;SQL is an ANSI (American National Standards Institute) standard&lt;/li&gt;
&lt;/ul&gt;&lt;hr style=&quot;background-color: #d4d4d4; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: both; color: #d4d4d4; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px; height: 1px;&quot; /&gt;&lt;h2 style=&quot;background-color: transparent; font-family: verdana, helvetica, arial, sans-serif; font-size: 19px; font-weight: normal; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;What Can SQL do?&lt;/span&gt;&lt;/h2&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;&lt;li&gt;SQL can execute queries against a database&lt;/li&gt;
&lt;li&gt;SQL can retrieve data from a database&lt;/li&gt;
&lt;li&gt;SQL can insert records in a database&lt;/li&gt;
&lt;li&gt;SQL can update records in a database&lt;/li&gt;
&lt;li&gt;SQL can delete records from a database&lt;/li&gt;
&lt;li&gt;SQL can create new databases&lt;/li&gt;
&lt;li&gt;SQL can create new tables in a database&lt;/li&gt;
&lt;li&gt;SQL can create stored procedures in a database&lt;/li&gt;
&lt;li&gt;SQL can create views in a database&lt;/li&gt;
&lt;li&gt;SQL can set permissions on tables, procedures, and views&lt;/li&gt;
&lt;/ul&gt;&lt;hr style=&quot;background-color: #d4d4d4; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: both; color: #d4d4d4; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px; height: 1px;&quot; /&gt;&lt;h2 style=&quot;background-color: transparent; font-family: verdana, helvetica, arial, sans-serif; font-size: 19px; font-weight: normal; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;SQL is a Standard - BUT....&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;Although SQL is an ANSI (American National Standards Institute) standard, there are many different versions of the SQL language.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;&lt;b&gt;Note:&lt;/b&gt;&amp;nbsp;Most of the SQL database programs also have their own proprietary extensions in addition to the SQL standard!&lt;/div&gt;&lt;hr style=&quot;background-color: #d4d4d4; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: both; color: #d4d4d4; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px; height: 1px;&quot; /&gt;&lt;h2 style=&quot;background-color: transparent; font-family: verdana, helvetica, arial, sans-serif; font-size: 19px; font-weight: normal; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;Using SQL in Your Web Site&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;To build a web site that shows some data from a database, you will need the following:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;&lt;li&gt;An RDBMS database program (i.e. MS Access, SQL Server, MySQL)&lt;/li&gt;
&lt;li&gt;A server-side scripting language, like PHP or ASP&lt;/li&gt;
&lt;li&gt;SQL&lt;/li&gt;
&lt;li&gt;HTML / CSS&lt;/li&gt;
&lt;/ul&gt;&lt;hr style=&quot;background-color: #d4d4d4; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: both; color: #d4d4d4; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px; height: 1px;&quot; /&gt;&lt;h2 style=&quot;background-color: transparent; font-family: verdana, helvetica, arial, sans-serif; font-size: 19px; font-weight: normal; margin-bottom: 10px; margin-top: 10px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;RDBMS&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;RDBMS stands for Relational Database Management System.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;The data in RDBMS is stored in database objects called tables.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 12px;&quot;&gt;A table is a collections of related data entries and it consists of columns and rows.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; line-height: 24px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot; valign=&quot;middle&quot; width=&quot;100&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;img alt=&quot;SQL Logo&quot; border=&quot;0&quot; src=&quot;http://www.tutorialspoint.com/images/sql.jpg&quot; style=&quot;border-color: initial; border-color: initial; border-style: initial; border-top-style: solid; border-width: initial; padding-right: 5px;&quot; /&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot; valign=&quot;top&quot;&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;SQL is a database computer language designed for the retrieval and management of data in relational database.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;SQL stands for&amp;nbsp;&lt;u&gt;S&lt;/u&gt;tructured&amp;nbsp;&lt;u&gt;Q&lt;/u&gt;uery&amp;nbsp;&lt;u&gt;L&lt;/u&gt;anguage.&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;This tutorial will give you quick start with SQL.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/7080893226440131058/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-is-database-computer-language_3968.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/7080893226440131058'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/7080893226440131058'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-is-database-computer-language_3968.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-2003933129221082268</id><published>2010-09-01T03:46:00.001-07:00</published><updated>2011-04-10T04:39:52.254-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The SQL&amp;nbsp;&lt;b&gt;LIKE&lt;/b&gt;&amp;nbsp;clause is used to compare a value to similar values using wildcard operators. There are two wildcards used in conjunction with the LIKE operator:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The percent sign (%)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The underscore (_)&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The percent sign represents zero, one, or multiple characters. The underscore represents a single number or character. The symbols can be used in combinations.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of % and _ is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT FROM table_name
WHERE column LIKE &#39;XXXX%&#39;

or 

SELECT FROM table_name
WHERE column LIKE &#39;%XXXX%&#39;

or

SELECT FROM table_name
WHERE column LIKE &#39;XXXX_&#39;

or

SELECT FROM table_name
WHERE column LIKE &#39;_XXXX&#39;

or

SELECT FROM table_name
WHERE column LIKE &#39;_XXXX_&#39;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;You can combine N number of conditions using AND or OR operators. Here XXXX could be any numberic or string value.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Here are number of examples showing WHERE part having different LIKE clause with &#39;%&#39; and &#39;_&#39; operators:&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;30%&quot;&gt;Statement&lt;/th&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;70%&quot;&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;200%&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that start with 200&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;%200%&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that have 200 in any position&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;_00%&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that have 00 in the second and third positions&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;2_%_%&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that start with 2 and are at least 3 characters in length&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;%2&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that end with 2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;_2%3&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that have a 2 in the second position and end with a 3&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;2___3&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values in a five-digit number that start with 2 and end with 3&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Let us take a real example, consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is an example which would display all the records from CUSTOMERS table where SALARY starts with 200:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT * FROM CUSTOMERS
WHERE SALARY LIKE &#39;200%&#39;;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/2003933129221082268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-like-is-used-to-compare-value-to_01.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/2003933129221082268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/2003933129221082268'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-like-is-used-to-compare-value-to_01.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-6334105386117295498</id><published>2010-09-01T03:35:00.001-07:00</published><updated>2011-04-10T04:39:52.254-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The HAVING clause enables you to specify conditions that filter which group results appear in the final results.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The WHERE clause places conditions on the selected columns, whereas the HAVING clause places conditions on groups created by the GROUP BY clause.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The following is the position of the HAVING clause in a query:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The HAVING clause must follow the GROUP BY clause in a query and must also precede the ORDER BY clause if used. The following is the syntax of the SELECT statement, including the HAVING clause:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1, column2
FROM table1, table2
WHERE [ conditions ]
GROUP BY column1, column2
HAVING [ conditions ]
ORDER BY column1, column2
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is the example which would display record for which similar age count would be more than or equal to 2:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL &amp;gt; SELECT *
FROM CUSTOMERS
GROUP BY age
HAVING COUNT(age) &amp;gt;= 2;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+--------+-----+---------+---------+
| ID | NAME   | AGE | ADDRESS | SALARY  |
+----+--------+-----+---------+---------+
|  2 | Khilan |  25 | Delhi   | 1500.00 |
+----+--------+-----+---------+---------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/6334105386117295498/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/having-clause-enables-you-to-specify.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/6334105386117295498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/6334105386117295498'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/having-clause-enables-you-to-specify.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-6416801950169108992</id><published>2010-09-01T03:28:00.001-07:00</published><updated>2011-04-10T04:39:52.255-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 9.16667px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;SQL - Useful Resources&lt;/h1&gt;&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt&quot; style=&quot;background-color: transparent; color: #900b09;&quot; target=&quot;_blank&quot;&gt;ANSI SQL&lt;/a&gt;&amp;nbsp;- Database Language SQL (Proposed revised text of DIS 9075) July 1992 (Second Informal Review Draft).&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/c0004100.htm&quot; style=&quot;background-color: transparent; color: #900b09;&quot; target=&quot;_blank&quot;&gt;Structured Query Language (SQL):&lt;/a&gt;&amp;nbsp;- DB2 resource for SQL users.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;http://www.oracle.com/technology/products/database/sql_developer/index.html&quot; style=&quot;background-color: transparent; color: #900b09;&quot; target=&quot;_blank&quot;&gt;Oracle SQL Developer&lt;/a&gt;&amp;nbsp;- Oracle SQL Developer is a free and fully supported graphical tool for database development.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/SQL&quot; style=&quot;background-color: transparent; color: #900b09;&quot; target=&quot;_blank&quot;&gt;SQL at Wikipedia&lt;/a&gt;&amp;nbsp;- A small article on SQL, worth to go through it.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;http://www.mysql.com/&quot; style=&quot;background-color: transparent; color: #900b09;&quot; target=&quot;_blank&quot;&gt;MySQL Official Website&lt;/a&gt;&amp;nbsp;- Here you can download the latest MySQL release, get the MySQL news update. The mailing list is also a great resources for anyone who want to build dynamic websites using MySQL.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;&lt;a href=&quot;http://www.tutorialspoint.com/perl/perl_database.htm&quot; style=&quot;background-color: transparent; color: #900b09;&quot; target=&quot;_blank&quot;&gt;MySQL and PERL&lt;/a&gt;&amp;nbsp;- Its a tutorial from Tutorials Point which explains you how to use MySQL along with PERL and DBI module. Here you will learn all the required MySQL operations alongwith examples.&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/6416801950169108992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/if-you-want-to-list-down-your-website.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/6416801950169108992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/6416801950169108992'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/if-you-want-to-list-down-your-website.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-8903905275613596779</id><published>2010-09-01T03:27:00.001-07:00</published><updated>2011-04-10T04:39:52.255-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;SQL has many built-in functions for performing processing on string or numeric data. Following is the list of all useful SQL built-in functions:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL COUNT Function&lt;/span&gt;&amp;nbsp;- The SQL COUNT aggregate function is used to count the number of rows in a database table.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL MAX Function&lt;/span&gt;&amp;nbsp;- The SQL MAX aggregate function allows us to select the highest (maximum) value for a certain column.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL MIN Function&lt;/span&gt;&amp;nbsp;- The SQL MIN aggregate function allows us to select the lowest (minimum) value for a certain column.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL AVG Function&lt;/span&gt;&amp;nbsp;- The SQL AVG aggregate function selects the average value for certain table column.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL SUM Function&lt;/span&gt;&amp;nbsp;- The SQL SUM aggregate function allows selecting the total for a numeric column.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL SQRT Functions&lt;/span&gt;&amp;nbsp;- This is used to generate a square root of a given number.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL RAND Function&lt;/span&gt;&amp;nbsp;- This is used to generate a random number using SQL command.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL CONCAT Function&amp;nbsp;&lt;/span&gt;- This is used to concatenate any string inside any SQL command.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL Numeric Functions&lt;/span&gt;&amp;nbsp;- Complete list of SQL functions required to manipulate numbers in SQL.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: medium;&quot;&gt;SQL String Functions&amp;nbsp;&lt;/span&gt;- Complete list of SQL functions required to manipulate strings in SQL.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/8903905275613596779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-has-many-built-in-functions-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/8903905275613596779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/8903905275613596779'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-has-many-built-in-functions-for.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-274155014518494378</id><published>2010-09-01T03:25:00.003-07:00</published><updated>2011-04-10T04:39:52.255-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;If you take user input through a webpage and insert it into a SQL database there&#39;s a chance that you have left yourself wide open for a security issue known as SQL Injection.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This lesson will teach you how to help prevent this from happening and help you secure your scripts and SQL statements in your server side scripts such as PERL Script.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Injection usually occurs when you ask a user for input, like their name, and instead of a name they give you a SQL statement that you will unknowingly run on your database.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Never trust user provided data, process this data only after validation; as a rule, this is done by pattern matching.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;In the example below, the&amp;nbsp;&lt;b&gt;name&lt;/b&gt;&amp;nbsp;is restricted to alphanumerical chars plus underscore and to a length between 8 and 20 chars (Modify these rules as needed).&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;if (preg_match(&quot;/^\w{8,20}$/&quot;, $_GET[&#39;username&#39;], $matches))
{
   $result = mysql_query(&quot;SELECT * FROM CUSTOMERS 
                          WHERE name=$matches[0]&quot;);
}
else 
{
   echo &quot;user name not accepted&quot;;
}
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;To demonstrate the problem, consider this excerpt:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;// supposed input
$name = &quot;Qadir&#39;; DELETE FROM CUSTOMERS;&quot;;
mysql_query(&quot;SELECT * FROM CUSTOMSRS WHERE name=&#39;{$name}&#39;&quot;);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The function call is supposed to retrieve a record from the CUSTOMERS table where the name column matches the name specified by the user. Under normal circumstances, $name would only contain alphanumeric characters and perhaps spaces, such as the string ilia. But here, by appending an entirely new query to $name, the call to the database turns into disaster: the injected DELETE query removes all records from CUSTOMERS.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Fortunately, if you use MySQL, the mysql_query() function does not permit query stacking, or executing multiple SQL queries in a single function call. If you try to stack queries, the call fails.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;However, other PHP database extensions, such as SQLite and PostgreSQL, happily perform stacked queries, executing all of the queries provided in one string and creating a serious security problem.&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Preventing SQL Injection:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;You can handle all escape characters smartly in scripting languages like PERL and PHP. The MySQL extension for PHP provides the function mysql_real_escape_string() to escape input characters that are special to MySQL.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;if (get_magic_quotes_gpc()) 
{
  $name = stripslashes($name);
}
$name = mysql_real_escape_string($name);
mysql_query(&quot;SELECT * FROM CUSTOMERS WHERE name=&#39;{$name}&#39;&quot;);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;The LIKE Quandary:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;To address the LIKE quandary, a custom escaping mechanism must convert user-supplied % and _ characters to literals. Use addcslashes(), a function that let&#39;s you specify a character range to escape.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;$sub = addcslashes(mysql_real_escape_string(&quot;%str&quot;), &quot;%_&quot;);
// $sub == \%str\_
mysql_query(&quot;SELECT * FROM messages 
             WHERE subject LIKE &#39;{$sub}%&#39;&quot;);
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/274155014518494378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/if-you-take-user-input-through-webpage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/274155014518494378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/274155014518494378'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/if-you-take-user-input-through-webpage.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-8359999344422332588</id><published>2010-09-01T03:25:00.001-07:00</published><updated>2011-04-10T04:39:52.256-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;There may be a situation when you have multiple duplicate records in a table. While fetching such records, it makes more sense to fetch only unique records instead of fetching duplicate records.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The SQL&amp;nbsp;&lt;b&gt;DISTINCT&lt;/b&gt;&amp;nbsp;keyword, which we already have discussed, is used in conjunction with SELECT statement to eliminate all the duplicate records and fetching only unique records.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of DISTINCT keyword to eliminate duplicate records is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT DISTINCT column1, column2,.....columnN 
FROM table_name
WHERE [condition]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;First let us see how the following SELECT query returns duplicate salary records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT SALARY FROM CUSTOMERS
     ORDER BY SALARY;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result where salary 2000 is coming twice which is a duplicate record from the original table.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----------+
| SALARY   |
+----------+
|  1500.00 |
|  2000.00 |
|  2000.00 |
|  4500.00 |
|  6500.00 |
|  8500.00 |
| 10000.00 |
+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now let us use DISTINCT keywork with the above SELECT query and see the result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT DISTINCT SALARY FROM CUSTOMERS
     ORDER BY SALARY;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result where we do not have any duplicate entry:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----------+
| SALARY   |
+----------+
|  1500.00 |
|  2000.00 |
|  4500.00 |
|  6500.00 |
|  8500.00 |
| 10000.00 |
+----------+
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/8359999344422332588/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/there-may-be-situation-when-you-have.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/8359999344422332588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/8359999344422332588'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/there-may-be-situation-when-you-have.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-1939252968384577639</id><published>2010-09-01T03:24:00.005-07:00</published><updated>2011-04-10T04:39:52.256-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A sequence is a set of integers 1, 2, 3, ... that are generated in order on demand. Sequences are frequently used in databases because many applications require each row in a table to contain a unique value, and sequences provide an easy way to generate them.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This chapter describes how to use sequences in MySQL.&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Using AUTO_INCREMENT column:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The simplest way in MySQL to use Sequences is to define a column as AUTO_INCREMENT and leave rest of the things to MySQL to take care.&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Try out following example. This will create table and after that it will insert few rows in this table where it is not required to give record ID because its auto incremented by MySQL.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; CREATE TABLE INSECT
    -&amp;gt; (
    -&amp;gt; id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    -&amp;gt; PRIMARY KEY (id),
    -&amp;gt; name VARCHAR(30) NOT NULL, # type of insect
    -&amp;gt; date DATE NOT NULL, # date collected
    -&amp;gt; origin VARCHAR(30) NOT NULL # where collected
);
Query OK, 0 rows affected (0.02 sec)
mysql&amp;gt; INSERT INTO INSECT (id,name,date,origin) VALUES
    -&amp;gt; (NULL,&#39;housefly&#39;,&#39;2001-09-10&#39;,&#39;kitchen&#39;),
    -&amp;gt; (NULL,&#39;millipede&#39;,&#39;2001-09-10&#39;,&#39;driveway&#39;),
    -&amp;gt; (NULL,&#39;grasshopper&#39;,&#39;2001-09-10&#39;,&#39;front yard&#39;);
Query OK, 3 rows affected (0.02 sec)
Records: 3  Duplicates: 0  Warnings: 0
mysql&amp;gt; SELECT * FROM INSECT ORDER BY id;
+----+-------------+------------+------------+
| id | name        | date       | origin     |
+----+-------------+------------+------------+
|  1 | housefly    | 2001-09-10 | kitchen    |
|  2 | millipede   | 2001-09-10 | driveway   |
|  3 | grasshopper | 2001-09-10 | front yard |
+----+-------------+------------+------------+
3 rows in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Obtain AUTO_INCREMENT Values:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;LAST_INSERT_ID( ) is a SQL function, so you can use it from within any client that understands how to issue SQL statements. otherwise PERL and PHH scripts provide exclusive functions to retrieve auto incremented value of last record.&lt;/div&gt;&lt;h3 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px; text-align: justify;&quot;&gt;PERL Example:&lt;/h3&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Use the mysql_insertid attribute to obtain the AUTO_INCREMENT value generated by a query. This attribute is accessed through either a database handle or a statement handle, depending on how you issue the query. The following example references it through the database handle:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;$dbh-&amp;gt;do (&quot;INSERT INTO INSECT (name,date,origin)
VALUES(&#39;moth&#39;,&#39;2001-09-14&#39;,&#39;windowsill&#39;)&quot;);
my $seq = $dbh-&amp;gt;{mysql_insertid};
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h3 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px; text-align: justify;&quot;&gt;PHP Example:&lt;/h3&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;After issuing a query that generates an AUTO_INCREMENT value, retrieve the value by calling mysql_insert_id( ):&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql_query (&quot;INSERT INTO INSECT (name,date,origin)
VALUES(&#39;moth&#39;,&#39;2001-09-14&#39;,&#39;windowsill&#39;)&quot;, $conn_id);
$seq = mysql_insert_id ($conn_id);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Renumbering an Existing Sequence:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;There may be a case when you have deleted many records from a table and you want to resequence all the records. This can be done by using a simple trick but you should be very careful to do so if your table is having join with other table.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;If you determine that resequencing an AUTO_INCREMENT column is unavoidable, the way to do it is to drop the column from the table, then add it again. The following example shows how to renumber the id values in the insect table using this technique:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; ALTER TABLE INSECT DROP id;
mysql&amp;gt; ALTER TABLE insect
    -&amp;gt; ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
    -&amp;gt; ADD PRIMARY KEY (id);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Starting a Sequence at a Particular Value:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;By default MySQL will start sequence from 1 but you can specify any other number as well at the time of table creation. Following is the example where MySQL will start sequence from 100.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; CREATE TABLE INSECT
    -&amp;gt; (
    -&amp;gt; id INT UNSIGNED NOT NULL AUTO_INCREMENT = 100,
    -&amp;gt; PRIMARY KEY (id),
    -&amp;gt; name VARCHAR(30) NOT NULL, # type of insect
    -&amp;gt; date DATE NOT NULL, # date collected
    -&amp;gt; origin VARCHAR(30) NOT NULL # where collected
);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Alternatively, you can create the table and then set the initial sequence value with ALTER TABLE.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; ALTER TABLE t AUTO_INCREMENT = 100;
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/1939252968384577639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sequence-is-set-of-integers-1-2-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/1939252968384577639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/1939252968384577639'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sequence-is-set-of-integers-1-2-3.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-4918061969116883461</id><published>2010-09-01T03:24:00.001-07:00</published><updated>2011-04-10T04:39:52.256-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A Subquery or Inner query or Nested query is a query within another SQL query, and embedded within the WHERE clause.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A subquery is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along with the operators like =, &amp;lt;, &amp;gt;, &amp;gt;=, &amp;lt;=, IN, BETWEEN etc.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;There are a few rules that subqueries must follow:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Subqueries must be enclosed within parentheses.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;A subquery can have only one column in the SELECT clause, unless multiple columns are in the main query for the subquery to compare its selected columns.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;An ORDER BY cannot be used in a subquery, although the main query can use an ORDER BY. The GROUP BY can be used to perform the same function as the ORDER BY in a subquery.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Subqueries that return more than one row can only be used with multiple value operators, such as the IN operator.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The SELECT list cannot include any references to values that evaluate to a BLOB, ARRAY, CLOB, or NCLOB.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;A subquery cannot be immediately enclosed in a set function.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The BETWEEN operator cannot be used with a subquery; however, the BETWEEN can be used within the subquery.&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Subqueries with the SELECT Statement:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Subqueries are most frequently used with the SELECT statement. The basic syntax is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column_name [, column_name ]
FROM   table1 [, table2 ]
WHERE  column_name OPERATOR
      (SELECT column_name [, column_name ]
      FROM table1 [, table2 ]
      [WHERE])
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  35 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now let us check following sub-query with SELECT statement:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT * 
     FROM CUSTOMERS 
     WHERE ID IN (SELECT ID 
                  FROM CUSTOMERS 
                  WHERE SALARY &amp;gt; 4500) ;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+---------+----------+
| ID | NAME     | AGE | ADDRESS | SALARY   |
+----+----------+-----+---------+----------+
|  4 | Chaitali |  25 | Mumbai  |  6500.00 |
|  5 | Hardik   |  27 | Bhopal  |  8500.00 |
|  7 | Muffy    |  24 | Indore  | 10000.00 |
+----+----------+-----+---------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Subqueries with the INSERT Statement:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Subqueries also can be used with INSERT statements. The INSERT statement uses the data returned from the subquery to insert into another table. The selected data in the subquery can be modified with any of the character, date, or number functions.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;INSERT INTO table_name [ (column1 [, column2 ]) ]
           SELECT [ *|column1 [, column2 ]
           FROM table1 [, table2 ]
           [ WHERE VALUE OPERATOR ]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider a table CUSTOMERS_BKP with similar structure as CUSTOMERS table. Now to copy complete CUSTOMERS table into CUSTOMERS_BKP, following is the syntax:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; INSERT INTO CUSTOMERS_BKP
     SELECT * FROM CUSTOMERS 
     WHERE ID IN (SELECT ID 
                  FROM CUSTOMERS) ;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Subqueries with the UPDATE Statement:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The subquery can be used in conjunction with the UPDATE statement. Either single or multiple columns in a table can be updated when using a subquery with the UPDATE statement.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;UPDATE table
SET column_name = new_value
[ WHERE OPERATOR [ VALUE ]
   (SELECT COLUMN_NAME
   FROM TABLE_NAME)
   [ WHERE) ]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Assuming, we have CUSTOMERS_BKP table available which is backup of CUSTOMERS table.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following example updates SALARY by 0.25 times in CUSTOMERS table for all the customers whose AGE is greater than or equal to 27:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; UPDATE CUSTOMERS
     SET SALARY = SALARY * 0.25
     WHERE AGE IN (SELECT AGE FROM CUSTOMERS_BKP
                   WHERE AGE &amp;gt;= 27 );
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would impact two rows and finally CUSTOMERS table would have following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  35 | Ahmedabad |   125.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  2125.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Subqueries with the DELETE Statement:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The subquery can be used in conjunction with the DELETE statement like with any other statements mentioned above.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;DELETE FROM TABLE_NAME
[ WHERE OPERATOR [ VALUE ]
   (SELECT COLUMN_NAME
   FROM TABLE_NAME)
   [ WHERE) ]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Assuming, we have CUSTOMERS_BKP table available which is backup of CUSTOMERS table.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following example deletes records from CUSTOMERS table for all the customers whose AGE is greater than or equal to 27:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; DELETE FROM CUSTOMERS
     WHERE AGE IN (SELECT AGE FROM CUSTOMERS_BKP
                   WHERE AGE &amp;gt; 27 );
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would impact two rows and finally CUSTOMERS table would have following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+---------+----------+
| ID | NAME     | AGE | ADDRESS | SALARY   |
+----+----------+-----+---------+----------+
|  2 | Khilan   |  25 | Delhi   |  1500.00 |
|  3 | kaushik  |  23 | Kota    |  2000.00 |
|  4 | Chaitali |  25 | Mumbai  |  6500.00 |
|  6 | Komal    |  22 | MP      |  4500.00 |
|  7 | Muffy    |  24 | Indore  | 10000.00 |
+----+----------+-----+---------+----------+
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/4918061969116883461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/subquery-or-inner-query-or-nested-query.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/4918061969116883461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/4918061969116883461'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/subquery-or-inner-query-or-nested-query.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-3047571295803224931</id><published>2010-09-01T03:23:00.003-07:00</published><updated>2011-04-10T04:39:52.257-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;There may be a situation when you need an exact copy of a table, and CREATE TABLE ... SELECT... doesn&#39;t suit your purposes because the copy must include the same indexes, default values, and so forth.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;If you are using MySQL RDBMS, you can handle this situation by following steps.&lt;/div&gt;&lt;ol style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Use SHOW CREATE TABLE command to get a CREATE TABLE statement that specifies the source table&#39;s structure, indexes and all.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Modify the statement to change the table name to that of the clone table and execute the statement. This way you will have exact clone table.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Optionally, If you need the table contents copied as well, issue an INSERT INTO ... SELECT statement, too.&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Try out following example to create a clone table for&amp;nbsp;&lt;b&gt;TUTORIALS_TBL&lt;/b&gt;&amp;nbsp;whose structure is as follows:&lt;/div&gt;&lt;h3 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px; text-align: justify;&quot;&gt;Step 1:&lt;/h3&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Get complete structure about table&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SHOW CREATE TABLE TUTORIALS_TBL \G;
*************************** 1. row ***************************
       Table: TUTORIALS_TBL
Create Table: CREATE TABLE `TUTORIALS_TBL` (
  `tutorial_id` int(11) NOT NULL auto_increment,
  `tutorial_title` varchar(100) NOT NULL default &#39;&#39;,
  `tutorial_author` varchar(40) NOT NULL default &#39;&#39;,
  `submission_date` date default NULL,
  PRIMARY KEY  (`tutorial_id`),
  UNIQUE KEY `AUTHOR_INDEX` (`tutorial_author`)
) TYPE=MyISAM
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h3 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px; text-align: justify;&quot;&gt;Step 2:&lt;/h3&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Rename this table and create another table&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; CREATE TABLE `CLONE_TBL` (
  -&amp;gt; `tutorial_id` int(11) NOT NULL auto_increment,
  -&amp;gt; `tutorial_title` varchar(100) NOT NULL default &#39;&#39;,
  -&amp;gt; `tutorial_author` varchar(40) NOT NULL default &#39;&#39;,
  -&amp;gt; `submission_date` date default NULL,
  -&amp;gt; PRIMARY KEY  (`tutorial_id`),
  -&amp;gt; UNIQUE KEY `AUTHOR_INDEX` (`tutorial_author`)
-&amp;gt; ) TYPE=MyISAM;
Query OK, 0 rows affected (1.80 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h3 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 12px; text-align: justify;&quot;&gt;Step 3:&lt;/h3&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;After executing step 2 you will a clone table in your database. If you want to copy data from old table then you can do it by using INSERT INTO... SELECT statement.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; INSERT INTO CLONE_TBL (tutorial_id,
    -&amp;gt;                        tutorial_title,
    -&amp;gt;                        tutorial_author,
    -&amp;gt;                        submission_date)
    -&amp;gt; SELECT tutorial_id,tutorial_title,
    -&amp;gt;        tutorial_author,submission_date,
    -&amp;gt; FROM TUTORIALS_TBL;
Query OK, 3 rows affected (0.07 sec)
Records: 3  Duplicates: 0  Warnings: 0
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Finally you will have exact clone table as you wanted to have.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/3047571295803224931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/there-may-be-situation-when-you-need.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/3047571295803224931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/3047571295803224931'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/there-may-be-situation-when-you-need.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-7074257903851626598</id><published>2010-09-01T03:23:00.001-07:00</published><updated>2011-04-10T04:39:52.257-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;There are RDBMS which support temporary tables. Temporary Tables are a great feature that lets you store and process intermediate results by using the same selection, update, and join capabilities that you can use with typical SQL Server tables.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The temporary tables could be very useful in some cases to keep temporary data. The most important thing that should be knows for temporary tables is that they will be deleted when the current client session terminates.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Temporary tables are available in MySQL version 3.23 onwards. If you use an older version of MySQL than 3.23 you can&#39;t use temporary tables, but you can use heap tables.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;As stated earlier temporary tables will only last as long as the session is alive. If you run the code in a PHP script, the temporary table will be destroyed automatically when the script finishes executing. If you are connected to the MySQL database server through the MySQL client program, then the temporary table will exist until you close the client or manually destroy the table.&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Here is an example showing you usage of temporary table:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 482px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; CREATE TEMPORARY TABLE SALESSUMMARY (
    -&amp;gt; product_name VARCHAR(50) NOT NULL
    -&amp;gt; , total_sales DECIMAL(12,2) NOT NULL DEFAULT 0.00
    -&amp;gt; , avg_unit_price DECIMAL(7,2) NOT NULL DEFAULT 0.00
    -&amp;gt; , total_units_sold INT UNSIGNED NOT NULL DEFAULT 0
);
Query OK, 0 rows affected (0.00 sec)

mysql&amp;gt; INSERT INTO SALESSUMMARY
    -&amp;gt; (product_name, total_sales, avg_unit_price, total_units_sold)
    -&amp;gt; VALUES
    -&amp;gt; (&#39;cucumber&#39;, 100.25, 90, 2);

mysql&amp;gt; SELECT * FROM SALESSUMMARY;
+--------------+-------------+----------------+------------------+
| product_name | total_sales | avg_unit_price | total_units_sold |
+--------------+-------------+----------------+------------------+
| cucumber     |      100.25 |          90.00 |                2 |
+--------------+-------------+----------------+------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;When you issue a&amp;nbsp;&lt;b&gt;SHOW TABLES&lt;/b&gt;&amp;nbsp;command then your temporary table would not be listed out in the list. Now if you will log out of the MySQL session and then you will issue a SELECT command then you will find no data available in the database. Even your temporary table would also not exist.&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Dropping Temporary Tables:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;By default all the temporary tables are deleted by MySQL when your database connection gets terminated. Still you want to delete them in between then you do so by issuing DROP TABLE command.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is the example on dropping a temproary table.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 482px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; CREATE TEMPORARY TABLE SALESSUMMARY (
    -&amp;gt; product_name VARCHAR(50) NOT NULL
    -&amp;gt; , total_sales DECIMAL(12,2) NOT NULL DEFAULT 0.00
    -&amp;gt; , avg_unit_price DECIMAL(7,2) NOT NULL DEFAULT 0.00
    -&amp;gt; , total_units_sold INT UNSIGNED NOT NULL DEFAULT 0
);
Query OK, 0 rows affected (0.00 sec)

mysql&amp;gt; INSERT INTO SALESSUMMARY
    -&amp;gt; (product_name, total_sales, avg_unit_price, total_units_sold)
    -&amp;gt; VALUES
    -&amp;gt; (&#39;cucumber&#39;, 100.25, 90, 2);

mysql&amp;gt; SELECT * FROM SALESSUMMARY;
+--------------+-------------+----------------+------------------+
| product_name | total_sales | avg_unit_price | total_units_sold |
+--------------+-------------+----------------+------------------+
| cucumber     |      100.25 |          90.00 |                2 |
+--------------+-------------+----------------+------------------+
1 row in set (0.00 sec)
mysql&amp;gt; DROP TABLE SALESSUMMARY;
mysql&amp;gt;  SELECT * FROM SALESSUMMARY;
ERROR 1146: Table &#39;TUTORIALS.SALESSUMMARY&#39; doesn&#39;t exist
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/7074257903851626598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/there-are-rdbms-which-support-temporary.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/7074257903851626598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/7074257903851626598'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/there-are-rdbms-which-support-temporary.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-3953461815897558619</id><published>2010-09-01T03:22:00.000-07:00</published><updated>2011-04-10T04:39:52.258-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Following is the list of all important Date and Time related functions available through SQL. There are various other functions supported by your RDBMS. Given list is based on MySQL RDBMS.&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;strong&gt;Name&lt;/strong&gt;&lt;/th&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;ADDDATE()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Add dates&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;ADDTIME()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Add time&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;CONVERT_TZ()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Convert from one timezone to another&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;CURDATE()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the current date&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;CURRENT_DATE(), CURRENT_DATE&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Synonyms for CURDATE()&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;CURRENT_TIME(), CURRENT_TIME&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Synonyms for CURTIME()&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Synonyms for NOW()&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;CURTIME()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the current time&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DATE_ADD()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Add two dates&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DATE_FORMAT()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Format date as specified&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DATE_SUB()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Subtract two dates&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DATE()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Extract the date part of a date or datetime expression&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DATEDIFF()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Subtract two dates&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAY()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Synonym for DAYOFMONTH()&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAYNAME()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the name of the weekday&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAYOFMONTH()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the day of the month (1-31)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAYOFWEEK()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the weekday index of the argument&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAYOFYEAR()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the day of the year (1-366)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;EXTRACT&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Extract part of a date&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;FROM_DAYS()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Convert a day number to a date&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;FROM_UNIXTIME()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Format date as a UNIX timestamp&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;HOUR()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Extract the hour&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;LAST_DAY&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the last day of the month for the argument&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;LOCALTIME(), LOCALTIME&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Synonym for NOW()&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;LOCALTIMESTAMP, LOCALTIMESTAMP()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Synonym for NOW()&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MAKEDATE()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Create a date from the year and day of year&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MAKETIME&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MAKETIME()&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MICROSECOND()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the microseconds from argument&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MINUTE()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the minute from the argument&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MONTH()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the month from the date passed&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MONTHNAME()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the name of the month&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;NOW()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the current date and time&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;PERIOD_ADD()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Add a period to a year-month&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;PERIOD_DIFF()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the number of months between periods&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;QUARTER()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the quarter from a date argument&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;SEC_TO_TIME()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Converts seconds to &#39;HH:MM:SS&#39; format&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;SECOND()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the second (0-59)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;STR_TO_DATE()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Convert a string to a date&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;SUBDATE()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;When invoked with three arguments a synonym for DATE_SUB()&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;SUBTIME()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Subtract times&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;SYSDATE()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the time at which the function executes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;TIME_FORMAT()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Format as time&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;TIME_TO_SEC()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the argument converted to seconds&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;TIME()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Extract the time portion of the expression passed&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;TIMEDIFF()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Subtract time&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;TIMESTAMP()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;With a single argument, this function returns the date or datetime expression. With two arguments, the sum of the arguments&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;TIMESTAMPADD()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Add an interval to a datetime expression&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;TIMESTAMPDIFF()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Subtract an interval from a datetime expression&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;TO_DAYS()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the date argument converted to days&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;UNIX_TIMESTAMP()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return a UNIX timestamp&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;UTC_DATE()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the current UTC date&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;UTC_TIME()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the current UTC time&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;UTC_TIMESTAMP()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the current UTC date and time&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WEEK()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the week number&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WEEKDAY()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the weekday index&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WEEKOFYEAR()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the calendar week of the date (1-53)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;YEAR()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the year&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;YEARWEEK()&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Return the year and week&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_adddate&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;ADDDATE(date,INTERVAL expr unit), ADDDATE(expr,days)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;When invoked with the INTERVAL form of the second argument, ADDDATE() is a synonym for DATE_ADD(). The related function SUBDATE() is a synonym for DATE_SUB(). For information on the INTERVAL unit argument, see the discussion for DATE_ADD().&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DATE_ADD(&#39;1998-01-02&#39;, INTERVAL 31 DAY);
+---------------------------------------------------------+
| DATE_ADD(&#39;1998-01-02&#39;, INTERVAL 31 DAY)                 |
+---------------------------------------------------------+
| 1998-02-02                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql&amp;gt; SELECT ADDDATE(&#39;1998-01-02&#39;, INTERVAL 31 DAY);
+---------------------------------------------------------+
| ADDDATE(&#39;1998-01-02&#39;, INTERVAL 31 DAY)                  |
+---------------------------------------------------------+
| 1998-02-02                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;When invoked with the days form of the second argument, MySQL treats it as an integer number of days to be added to expr.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT ADDDATE(&#39;1998-01-02&#39;, 31);
+---------------------------------------------------------+
| DATE_ADD(&#39;1998-01-02&#39;, INTERVAL 31 DAY)                 |
+---------------------------------------------------------+
| 1998-02-02                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_addtime&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;ADDTIME(expr1,expr2)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;ADDTIME() adds expr2 to expr1 and returns the result. expr1 is a time or datetime expression, and expr2 is a time expression.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT ADDTIME(&#39;1997-12-31 23:59:59.999999&#39;,&#39;1 1:1:1.000002&#39;);
+---------------------------------------------------------+
| DATE_ADD(&#39;1997-12-31 23:59:59.999999&#39;,&#39;1 1:1:1.000002&#39;) |
+---------------------------------------------------------+
| 1998-01-02 01:01:01.000001                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_convert-tz&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;CONVERT_TZ(dt,from_tz,to_tz)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;This converts a datetime value dt from the time zone given by from_tz to the time zone given by to_tz and returns the resulting value. This function returns NULL if the arguments are invalid.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT CONVERT_TZ(&#39;2004-01-01 12:00:00&#39;,&#39;GMT&#39;,&#39;MET&#39;);
+---------------------------------------------------------+
| CONVERT_TZ(&#39;2004-01-01 12:00:00&#39;,&#39;GMT&#39;,&#39;MET&#39;)           |
+---------------------------------------------------------+
| 2004-01-01 13:00:00                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql&amp;gt; SELECT CONVERT_TZ(&#39;2004-01-01 12:00:00&#39;,&#39;+00:00&#39;,&#39;+10:00&#39;);
+---------------------------------------------------------+
| CONVERT_TZ(&#39;2004-01-01 12:00:00&#39;,&#39;+00:00&#39;,&#39;+10:00&#39;)     |
+---------------------------------------------------------+
| 2004-01-01 22:00:00                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_curdate&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;CURDATE()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the current date as a value in &#39;YYYY-MM-DD&#39; or YYYYMMDD format, depending on whether the function is used in a string or numeric context.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT CURDATE();
+---------------------------------------------------------+
| CURDATE()                                               |
+---------------------------------------------------------+
| 1997-12-15                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql&amp;gt; SELECT CURDATE() + 0;
+---------------------------------------------------------+
| CURDATE() + 0                                           |
+---------------------------------------------------------+
| 19971215                                                |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_current-date&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;CURRENT_DATE and CURRENT_DATE()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;CURRENT_DATE and CURRENT_DATE() are synonyms for CURDATE()&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_curtime&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;CURTIME()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the current time as a value in &#39;HH:MM:SS&#39; or HHMMSS format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT CURTIME();
+---------------------------------------------------------+
| CURTIME()                                               |
+---------------------------------------------------------+
| 23:50:26                                                |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql&amp;gt; SELECT CURTIME() + 0;
+---------------------------------------------------------+
| CURTIME() + 0                                           |
+---------------------------------------------------------+
| 235026                                                  |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_current-time&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;CURRENT_TIME and CURRENT_TIME()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;CURRENT_TIME and CURRENT_TIME() are synonyms for CURTIME().&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_current-timestamp&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;CURRENT_TIMESTAMP and CURRENT_TIMESTAMP()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;CURRENT_TIMESTAMP and CURRENT_TIMESTAMP() are synonyms for NOW().&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_date&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DATE(expr)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Extracts the date part of the date or datetime expression expr.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DATE(&#39;2003-12-31 01:02:03&#39;);
+---------------------------------------------------------+
| DATE(&#39;2003-12-31 01:02:03&#39;)                             |
+---------------------------------------------------------+
|  2003-12-31                                             |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_datediff&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DATEDIFF(expr1,expr2)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;DATEDIFF() returns expr1 . expr2 expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DATEDIFF(&#39;1997-12-31 23:59:59&#39;,&#39;1997-12-30&#39;);
+---------------------------------------------------------+
| DATEDIFF(&#39;1997-12-31 23:59:59&#39;,&#39;1997-12-30&#39;)            |
+---------------------------------------------------------+
| 1                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_date-add&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DATE_ADD(date,INTERVAL expr unit), DATE_SUB(date,INTERVAL expr unit)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;These functions perform date arithmetic. date is a DATETIME or DATE value specifying the starting date. expr is an expression specifying the interval value to be added or subtracted from the starting date. expr is a string; it may start with a .-. for negative intervals. unit is a keyword indicating the units in which the expression should be interpreted.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;The INTERVAL keyword and the unit specifier are not case sensitive.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;The following table shows the expected form of the expr argument for each unit value;&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;span&gt;unit&amp;nbsp;&lt;strong&gt;Value&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;strong&gt;Expected&lt;/strong&gt;expr&lt;strong&gt;Format&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MICROSECOND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MICROSECONDS&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;SECOND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;SECONDS&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MINUTE&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MINUTES&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;HOUR&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;HOURS&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAY&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAYS&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WEEK&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WEEKS&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MONTH&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MONTHS&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;QUARTER&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;QUARTERS&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;YEAR&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;YEARS&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;SECOND_MICROSECOND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;SECONDS.MICROSECONDS&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MINUTE_MICROSECOND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;MINUTES.MICROSECONDS&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;MINUTE_SECOND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;MINUTES:SECONDS&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;HOUR_MICROSECOND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;HOURS.MICROSECONDS&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;HOUR_SECOND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;HOURS:MINUTES:SECONDS&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;HOUR_MINUTE&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;HOURS:MINUTES&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAY_MICROSECOND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;DAYS.MICROSECONDS&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAY_SECOND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;DAYS HOURS:MINUTES:SECONDS&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAY_MINUTE&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;DAYS HOURS:MINUTES&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;DAY_HOUR&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;DAYS HOURS&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;YEAR_MONTH&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&#39;YEARS-MONTHS&#39;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;The values QUARTER and WEEK are available beginning with MySQL 5.0.0.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DATE_ADD(&#39;1997-12-31 23:59:59&#39;, 
    -&amp;gt; INTERVAL &#39;1:1&#39; MINUTE_SECOND);
+---------------------------------------------------------+
| DATE_ADD(&#39;1997-12-31 23:59:59&#39;, INTERVAL...             |
+---------------------------------------------------------+
| 1998-01-01 00:01:00                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql&amp;gt; SELECT DATE_ADD(&#39;1999-01-01&#39;, INTERVAL 1 HOUR);
+---------------------------------------------------------+
| DATE_ADD(&#39;1999-01-01&#39;, INTERVAL 1 HOUR)                 |
+---------------------------------------------------------+
| 1999-01-01 01:00:00                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_date-format&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DATE_FORMAT(date,format)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Formats the date value according to the format string.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;The following specifiers may be used in the format string. The .%. character is required before format specifier characters.&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;strong&gt;Specifier&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%a&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Abbreviated weekday name (Sun..Sat)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%b&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Abbreviated month name (Jan..Dec)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%c&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Month, numeric (0..12)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%D&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Day of the month with English suffix (0th, 1st, 2nd, 3rd, .)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%d&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Day of the month, numeric (00..31)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%e&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Day of the month, numeric (0..31)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%f&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Microseconds (000000..999999)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%H&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Hour (00..23)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%h&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Hour (01..12)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%I&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Hour (01..12)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%i&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Minutes, numeric (00..59)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%j&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Day of year (001..366)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%k&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Hour (0..23)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%l&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Hour (1..12)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%M&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Month name (January..December)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%m&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Month, numeric (00..12)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%p&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;AM or PM&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%r&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Time, 12-hour (hh:mm:ss followed by AM or PM)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%S&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Seconds (00..59)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%s&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Seconds (00..59)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%T&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Time, 24-hour (hh:mm:ss)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%U&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Week (00..53), where Sunday is the first day of the week&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%u&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Week (00..53), where Monday is the first day of the week&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%V&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Week (01..53), where Sunday is the first day of the week; used with %X&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%v&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Week (01..53), where Monday is the first day of the week; used with %x&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%W&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Weekday name (Sunday..Saturday)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%w&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Day of the week (0=Sunday..6=Saturday)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%X&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Year for the week where Sunday is the first day of the week, numeric, four digits; used with %V&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%x&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Year for the week, where Monday is the first day of the week, numeric, four digits; used with %v&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%Y&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Year, numeric, four digits&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%y&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Year, numeric (two digits)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%%&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;A literal .%. character&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%x&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;x, for any.x. not listed above&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DATE_FORMAT(&#39;1997-10-04 22:23:00&#39;, &#39;%W %M %Y&#39;);
+---------------------------------------------------------+
| DATE_FORMAT(&#39;1997-10-04 22:23:00&#39;, &#39;%W %M %Y&#39;)          |
+---------------------------------------------------------+
| Saturday October 1997                                   |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql&amp;gt; SELECT DATE_FORMAT(&#39;1997-10-04 22:23:00&#39;
    -&amp;gt; &#39;%H %k %I %r %T %S %w&#39;);
+---------------------------------------------------------+
| DATE_FORMAT(&#39;1997-10-04 22:23:00.......                 |
+---------------------------------------------------------+
|  22 22 10 10:23:00 PM 22:23:00 00 6                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_date-sub&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DATE_SUB(date,INTERVAL expr unit)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;This is similar to DATE_ADD() function.&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_day&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DAY(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;DAY() is a synonym for DAYOFMONTH().&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_dayname&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DAYNAME(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the name of the weekday for date.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DAYNAME(&#39;1998-02-05&#39;);
+---------------------------------------------------------+
| DAYNAME(&#39;1998-02-05&#39;)                                   |
+---------------------------------------------------------+
| Thursday                                                |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_dayofmonth&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DAYOFMONTH(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the day of the month for date, in the range 0 to 31.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DAYOFMONTH(&#39;1998-02-03&#39;);
+---------------------------------------------------------+
| DAYOFMONTH(&#39;1998-02-03&#39;)                                |
+---------------------------------------------------------+
| 3                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_dayofweek&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DAYOFWEEK(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the weekday index for date (1 = Sunday, 2 = Monday, ., 7 = Saturday). These index values correspond to the ODBC standard.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DAYOFWEEK(&#39;1998-02-03&#39;);
+---------------------------------------------------------+
|DAYOFWEEK(&#39;1998-02-03&#39;)                                  |
+---------------------------------------------------------+
| 3                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_dayofyear&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;DAYOFYEAR(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the day of the year for date, in the range 1 to 366.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DAYOFYEAR(&#39;1998-02-03&#39;);
+---------------------------------------------------------+
| DAYOFYEAR(&#39;1998-02-03&#39;)                                 |
+---------------------------------------------------------+
| 34                                                      |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_extract&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;EXTRACT(unit FROM date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;The EXTRACT() function uses the same kinds of unit specifiers as DATE_ADD() or DATE_SUB(), but extracts parts from the date rather than performing date arithmetic.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT EXTRACT(YEAR FROM &#39;1999-07-02&#39;);
+---------------------------------------------------------+
| EXTRACT(YEAR FROM &#39;1999-07-02&#39;)                         |
+---------------------------------------------------------+
| 1999                                                    |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql&amp;gt; SELECT EXTRACT(YEAR_MONTH FROM &#39;1999-07-02 01:02:03&#39;);
+---------------------------------------------------------+
| EXTRACT(YEAR_MONTH FROM &#39;1999-07-02 01:02:03&#39;)          |
+---------------------------------------------------------+
| 199907                                                  |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_from-days&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;FROM_DAYS(N)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Given a day number N, returns a DATE value.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT FROM_DAYS(729669);
+---------------------------------------------------------+
| FROM_DAYS(729669)                                       |
+---------------------------------------------------------+
| 1997-10-07                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Use FROM_DAYS() with caution on old dates. It is not intended for use with values that precede the advent of the Gregorian calendar (1582).&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_from-unixtime&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;FROM_UNIXTIME(unix_timestamp)&lt;/h2&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;FROM_UNIXTIME(unix_timestamp,format)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns a representation of the unix_timestamp argument as a value in &#39;YYYY-MM-DD HH:MM:SS&#39; or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone. unix_timestamp is an internal timestamp value such as is produced by the UNIX_TIMESTAMP() function.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;If format is given, the result is formatted according to the format string, which is used the same way as listed in the entry for the DATE_FORMAT() function.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT FROM_UNIXTIME(875996580);
+---------------------------------------------------------+
| FROM_UNIXTIME(875996580)                                |
+---------------------------------------------------------+
| 1997-10-04 22:23:00                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_hour&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;HOUR(time)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the hour for time. The range of the return value is 0 to 23 for time-of-day values. However, the range of TIME values actually is much larger, so HOUR can return values greater than 23.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT HOUR(&#39;10:05:03&#39;);
+---------------------------------------------------------+
| HOUR(&#39;10:05:03&#39;)                                        |
+---------------------------------------------------------+
| 10                                                      |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_last-day&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;LAST_DAY(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Takes a date or datetime value and returns the corresponding value for the last day of the month. Returns NULL if the argument is invalid.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT LAST_DAY(&#39;2003-02-05&#39;);
+---------------------------------------------------------+
| LAST_DAY(&#39;2003-02-05&#39;)                                  |
+---------------------------------------------------------+
| 2003-02-28                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_localtime&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;LOCALTIME and LOCALTIME()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;LOCALTIME and LOCALTIME() are synonyms for NOW().&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_localtimestamp&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;LOCALTIMESTAMP and LOCALTIMESTAMP()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;LOCALTIMESTAMP and LOCALTIMESTAMP() are synonyms for NOW().&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_makedate&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;MAKEDATE(year,dayofyear)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns a date, given year and day-of-year values. dayofyear must be greater than 0 or the result is NULL.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT MAKEDATE(2001,31), MAKEDATE(2001,32);
+---------------------------------------------------------+
| MAKEDATE(2001,31), MAKEDATE(2001,32)                    |
+---------------------------------------------------------+
| &#39;2001-01-31&#39;, &#39;2001-02-01&#39;                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_maketime&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;MAKETIME(hour,minute,second)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns a time value calculated from the hour, minute, and second arguments.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT MAKETIME(12,15,30);
+---------------------------------------------------------+
| MAKETIME(12,15,30)                                      |
+---------------------------------------------------------+
| &#39;12:15:30&#39;                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_microsecond&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;MICROSECOND(expr)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the microseconds from the time or datetime expression expr as a number in the range from 0 to 999999.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT MICROSECOND(&#39;12:00:00.123456&#39;);
+---------------------------------------------------------+
| MICROSECOND(&#39;12:00:00.123456&#39;)                          |
+---------------------------------------------------------+
| 123456                                                  |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_minute&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;MINUTE(time)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the minute for time, in the range 0 to 59.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT MINUTE(&#39;98-02-03 10:05:03&#39;);
+---------------------------------------------------------+
| MINUTE(&#39;98-02-03 10:05:03&#39;)                             |
+---------------------------------------------------------+
| 5                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_month&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;MONTH(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the month for date, in the range 0 to 12.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT MONTH(&#39;1998-02-03&#39;)
+---------------------------------------------------------+
| MONTH(&#39;1998-02-03&#39;)                                     |
+---------------------------------------------------------+
| 2                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_monthname&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;MONTHNAME(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the full name of the month for date.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT MONTHNAME(&#39;1998-02-05&#39;);
+---------------------------------------------------------+
| MONTHNAME(&#39;1998-02-05&#39;)                                 |
+---------------------------------------------------------+
| February                                                |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_now&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;NOW()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the current date and time as a value in &#39;YYYY-MM-DD HH:MM:SS&#39; or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT NOW();
+---------------------------------------------------------+
| NOW()                                                   |
+---------------------------------------------------------+
| 1997-12-15 23:50:26                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_period-add&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;PERIOD_ADD(P,N)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Adds N months to period P (in the format YYMM or YYYYMM). Returns a value in the format YYYYMM. Note that the period argument P is not a date value.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT PERIOD_ADD(9801,2);
+---------------------------------------------------------+
| PERIOD_ADD(9801,2)                                      |
+---------------------------------------------------------+
| 199803                                                  |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_period-diff&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;PERIOD_DIFF(P1,P2)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the number of months between periods P1 and P2. P1 and P2 should be in the format YYMM or YYYYMM. Note that the period arguments P1 and P2 are not date values.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT PERIOD_DIFF(9802,199703);
+---------------------------------------------------------+
| PERIOD_DIFF(9802,199703)                                |
+---------------------------------------------------------+
| 11                                                      |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_quarter&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;QUARTER(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the quarter of the year for date, in the range 1 to 4.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT QUARTER(&#39;98-04-01&#39;);
+---------------------------------------------------------+
| QUARTER(&#39;98-04-01&#39;)                                     |
+---------------------------------------------------------+
| 2                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_second&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SECOND(time)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the second for time, in the range 0 to 59.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT SECOND(&#39;10:05:03&#39;);
+---------------------------------------------------------+
| SECOND(&#39;10:05:03&#39;)                                      |
+---------------------------------------------------------+
| 3                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_sec-to-time&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SEC_TO_TIME(seconds)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the seconds argument, converted to hours, minutes, and seconds, as a value in &#39;HH:MM:SS&#39; or HHMMSS format, depending on whether the function is used in a string or numeric context.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT SEC_TO_TIME(2378);
+---------------------------------------------------------+
| SEC_TO_TIME(2378)                                       |
+---------------------------------------------------------+
| 00:39:38                                                |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_str-to-date&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;STR_TO_DATE(str,format)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;This is the inverse of the DATE_FORMAT() function. It takes a string str and a format string format. STR_TO_DATE() returns a DATETIME value if the format string contains both date and time parts, or a DATE or TIME value if the string contains only date or time parts.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT STR_TO_DATE(&#39;04/31/2004&#39;, &#39;%m/%d/%Y&#39;);
+---------------------------------------------------------+
| STR_TO_DATE(&#39;04/31/2004&#39;, &#39;%m/%d/%Y&#39;)                   |
+---------------------------------------------------------+
| 2004-04-31                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_subdate&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SUBDATE(date,INTERVAL expr unit) and SUBDATE(expr,days)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;When invoked with the INTERVAL form of the second argument, SUBDATE() is a synonym for DATE_SUB(). For information on the INTERVAL unit argument, see the discussion for DATE_ADD().&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT DATE_SUB(&#39;1998-01-02&#39;, INTERVAL 31 DAY);
+---------------------------------------------------------+
| DATE_SUB(&#39;1998-01-02&#39;, INTERVAL 31 DAY)                 |
+---------------------------------------------------------+
| 1997-12-02                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql&amp;gt; SELECT SUBDATE(&#39;1998-01-02&#39;, INTERVAL 31 DAY);
+---------------------------------------------------------+
| SUBDATE(&#39;1998-01-02&#39;, INTERVAL 31 DAY)                  |
+---------------------------------------------------------+
| 1997-12-02                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_subtime&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SUBTIME(expr1,expr2)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;SUBTIME() returns expr1 . expr2 expressed as a value in the same format as expr1. expr1 is a time or datetime expression, and expr2 is a time.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT SUBTIME(&#39;1997-12-31 23:59:59.999999&#39;,
    -&amp;gt; &#39;1 1:1:1.000002&#39;);
+---------------------------------------------------------+
| SUBTIME(&#39;1997-12-31 23:59:59.999999&#39;...                 |
+---------------------------------------------------------+
| 1997-12-30 22:58:58.999997                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_sysdate&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SYSDATE()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the current date and time as a value in &#39;YYYY-MM-DD HH:MM:SS&#39; or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT SYSDATE();
+---------------------------------------------------------+
| SYSDATE()                                               |
+---------------------------------------------------------+
| 2006-04-12 13:47:44                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_time&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;TIME(expr)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Extracts the time part of the time or datetime expression expr and returns it as a string.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT TIME(&#39;2003-12-31 01:02:03&#39;);
+---------------------------------------------------------+
| TIME(&#39;2003-12-31 01:02:03&#39;)                             |
+---------------------------------------------------------+
| 01:02:03                                                |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_timediff&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;TIMEDIFF(expr1,expr2)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;TIMEDIFF() returns expr1 . expr2 expressed as a time value. expr1 and expr2 are time or date-and-time expressions, but both must be of the same type.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT TIMEDIFF(&#39;1997-12-31 23:59:59.000001&#39;,
    -&amp;gt; &#39;1997-12-30 01:01:01.000002&#39;);
+---------------------------------------------------------+
| TIMEDIFF(&#39;1997-12-31 23:59:59.000001&#39;.....              |
+---------------------------------------------------------+
|  46:58:57.999999                                        |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_timestamp&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;TIMESTAMP(expr), TIMESTAMP(expr1,expr2)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;With a single argument, this function returns the date or datetime expression expr as a datetime value. With two arguments, it adds the time expression expr2 to the date or datetime expression expr1 and returns the result as a datetime value.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT TIMESTAMP(&#39;2003-12-31&#39;);
+---------------------------------------------------------+
| TIMESTAMP(&#39;2003-12-31&#39;)                                 |
+---------------------------------------------------------+
| 2003-12-31 00:00:00                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_timestampadd&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;TIMESTAMPADD(unit,interval,datetime_expr)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Adds the integer expression interval to the date or datetime expression datetime_expr. The unit for interval is given by the unit argument, which should be one of the following values: FRAC_SECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, or YEAR.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;The unit value may be specified using one of keywords as shown, or with a prefix of SQL_TSI_. For example, DAY and SQL_TSI_DAY both are legal.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT TIMESTAMPADD(MINUTE,1,&#39;2003-01-02&#39;);
+---------------------------------------------------------+
| TIMESTAMPADD(MINUTE,1,&#39;2003-01-02&#39;)                     |
+---------------------------------------------------------+
| 2003-01-02 00:01:00                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a class=&quot;indexterm&quot; href=&quot;&quot; name=&quot;id3221361&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_timestampdiff&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the integer difference between the date or datetime expressions datetime_expr1 and datetime_expr2. The unit for the result is given by the unit argument. The legal values for unit are the same as those listed in the description of the TIMESTAMPADD() function.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT TIMESTAMPDIFF(MONTH,&#39;2003-02-01&#39;,&#39;2003-05-01&#39;);
+---------------------------------------------------------+
| TIMESTAMPDIFF(MONTH,&#39;2003-02-01&#39;,&#39;2003-05-01&#39;)          |
+---------------------------------------------------------+
| 3                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_time-format&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;TIME_FORMAT(time,format)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;This is used like the DATE_FORMAT() function, but the format string may contain format specifiers only for hours, minutes, and seconds.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;If the time value contains an hour part that is greater than 23, the %H and %k hour format specifiers produce a value larger than the usual range of 0..23. The other hour format specifiers produce the hour value modulo 12.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT TIME_FORMAT(&#39;100:00:00&#39;, &#39;%H %k %h %I %l&#39;);
+---------------------------------------------------------+
| TIME_FORMAT(&#39;100:00:00&#39;, &#39;%H %k %h %I %l&#39;)              |
+---------------------------------------------------------+
| 100 100 04 04 4                                         |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_time-to-sec&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;TIME_TO_SEC(time)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the time argument, converted to seconds.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT TIME_TO_SEC(&#39;22:23:00&#39;);
+---------------------------------------------------------+
| TIME_TO_SEC(&#39;22:23:00&#39;)                                 |
+---------------------------------------------------------+
| 80580                                                   |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_to-days&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;TO_DAYS(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Given a date date, returns a day number (the number of days since year 0).&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT TO_DAYS(950501);
+---------------------------------------------------------+
| TO_DAYS(950501)                                         |
+---------------------------------------------------------+
| 728779                                                  |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_unix-timestamp&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;UNIX_TIMESTAMP(), UNIX_TIMESTAMP(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;If called with no argument, returns a Unix timestamp (seconds since &#39;1970-01-01 00:00:00&#39; UTC) as an unsigned integer. If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since &#39;1970-01-01 00:00:00&#39; UTC. date may be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the format YYMMDD or YYYYMMDD.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT UNIX_TIMESTAMP();
+---------------------------------------------------------+
| UNIX_TIMESTAMP()                                        |
+---------------------------------------------------------+
| 882226357                                               |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql&amp;gt; SELECT UNIX_TIMESTAMP(&#39;1997-10-04 22:23:00&#39;);
+---------------------------------------------------------+
| UNIX_TIMESTAMP(&#39;1997-10-04 22:23:00&#39;)                   |
+---------------------------------------------------------+
| 875996580                                               |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_utc-date&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;UTC_DATE, UTC_DATE()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the current UTC date as a value in &#39;YYYY-MM-DD&#39; or YYYYMMDD format, depending on whether the function is used in a string or numeric context.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT UTC_DATE(), UTC_DATE() + 0;
+---------------------------------------------------------+
| UTC_DATE(), UTC_DATE() + 0                              |
+---------------------------------------------------------+
| 2003-08-14, 20030814                                    |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_utc-time&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;UTC_TIME, UTC_TIME()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the current UTC time as a value in &#39;HH:MM:SS&#39; or HHMMSS format, depending on whether the function is used in a string or numeric context.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT UTC_TIME(), UTC_TIME() + 0;
+---------------------------------------------------------+
| UTC_TIME(), UTC_TIME() + 0                              |
+---------------------------------------------------------+
| 18:07:53, 180753                                        |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_utc-timestamp&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;UTC_TIMESTAMP, UTC_TIMESTAMP()&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the current UTC date and time as a value in &#39;YYYY-MM-DD HH:MM:SS&#39; or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT UTC_TIMESTAMP(), UTC_TIMESTAMP() + 0;
+---------------------------------------------------------+
| UTC_TIMESTAMP(), UTC_TIMESTAMP() + 0                    |
+---------------------------------------------------------+
| 2003-08-14 18:08:04, 20030814180804                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_week&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;WEEK(date[,mode])&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;This function returns the week number for date. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;strong&gt;Mode&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;strong&gt;First Day of week&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;strong&gt;Range&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;strong&gt;Week 1 is the first week .&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;0&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Sunday&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;0-53&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;with a Sunday in this year&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;1&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Monday&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;0-53&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;with more than 3 days this year&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;2&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Sunday&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;1-53&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;with a Sunday in this year&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;3&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Monday&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;1-53&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;with more than 3 days this year&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;4&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Sunday&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;0-53&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;with more than 3 days this year&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;5&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Monday&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;0-53&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;with a Monday in this year&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;6&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Sunday&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;1-53&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;with more than 3 days this year&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;7&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Monday&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;1-53&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;with a Monday in this year&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT WEEK(&#39;1998-02-20&#39;);
+---------------------------------------------------------+
| WEEK(&#39;1998-02-20&#39;)                                      |
+---------------------------------------------------------+
| 7                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_weekday&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;WEEKDAY(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the weekday index for date (0 = Monday, 1 = Tuesday, . 6 = Sunday).&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT WEEKDAY(&#39;1998-02-03 22:23:00&#39;);
+---------------------------------------------------------+
| WEEKDAY(&#39;1998-02-03 22:23:00&#39;)                          |
+---------------------------------------------------------+
| 1                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_weekofyear&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;WEEKOFYEAR(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the calendar week of the date as a number in the range from 1 to 53. WEEKOFYEAR() is a compatibility function that is equivalent to WEEK(date,3).&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT WEEKOFYEAR(&#39;1998-02-20&#39;);
+---------------------------------------------------------+
| WEEKOFYEAR(&#39;1998-02-20&#39;)                                |
+---------------------------------------------------------+
| 8                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_year&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;YEAR(date)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns the year for date, in the range 1000 to 9999, or 0 for the .zero. date.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT YEAR(&#39;98-02-03&#39;);
+---------------------------------------------------------+
| YEAR(&#39;98-02-03&#39;)                                        |
+---------------------------------------------------------+
| 1998                                                    |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;a href=&quot;&quot; name=&quot;function_yearweek&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;YEARWEEK(date), YEARWEEK(date,mode)&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Returns year and week for a date. The mode argument works exactly like the mode argument to WEEK(). The year in the result may be different from the year in the date argument for the first and the last week of the year.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 489px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;mysql&amp;gt; SELECT YEARWEEK(&#39;1987-01-01&#39;);
+---------------------------------------------------------+
| YEAR(&#39;98-02-03&#39;)YEARWEEK(&#39;1987-01-01&#39;)                  |
+---------------------------------------------------------+
| 198653                                                  |
+---------------------------------------------------------+
1 row in set (0.00 sec)
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Note that the week number is different from what the WEEK() function would return (0) for optional arguments 0 or 1, as WEEK() then returns the week in the context of the given year.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/3953461815897558619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/blog-post.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/3953461815897558619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/3953461815897558619'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/blog-post.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-128507322961789663</id><published>2010-09-01T03:18:00.003-07:00</published><updated>2011-04-10T04:39:52.258-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;We already have discussed SQL&amp;nbsp;&lt;b&gt;LIKE&lt;/b&gt;&amp;nbsp;operator which is used to compare a value to similar values using wildcard operators.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;SQL supports following two wildcard operators in conjunction with the LIKE operator:&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;30%&quot;&gt;Wildcards&lt;/th&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;70%&quot;&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The percent sign (%)&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Matches one or more characters. Note that MS Access uses the asterisk (*) wildcard character instead of the percent sign (%) wildcard character.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The underscore (_)&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Matches one character. Note that MS Access uses a question mark (?) instead of the underscore (_) to match any one character.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The percent sign represents zero, one, or multiple characters. The underscore represents a single number or character. The symbols can be used in combinations.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of % and _ is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT FROM table_name
WHERE column LIKE &#39;XXXX%&#39;

or 

SELECT FROM table_name
WHERE column LIKE &#39;%XXXX%&#39;

or

SELECT FROM table_name
WHERE column LIKE &#39;XXXX_&#39;

or

SELECT FROM table_name
WHERE column LIKE &#39;_XXXX&#39;

or

SELECT FROM table_name
WHERE column LIKE &#39;_XXXX_&#39;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;You can combine N number of conditions using AND or OR operators. Here XXXX could be any numberic or string value.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Here are number of examples showing WHERE part having different LIKE clause with &#39;%&#39; and &#39;_&#39; operators:&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;30%&quot;&gt;Statement&lt;/th&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;70%&quot;&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;200%&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that start with 200&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;%200%&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that have 200 in any position&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;_00%&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that have 00 in the second and third positions&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;2_%_%&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that start with 2 and are at least 3 characters in length&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;%2&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that end with 2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;_2%3&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values that have a 2 in the second position and end with a 3&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;WHERE SALARY LIKE &#39;2___3&#39;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Finds any values in a five-digit number that start with 2 and end with 3&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Let us take a real example, consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is an example which would display all the records from CUSTOMERS table where SALARY starts with 200:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT * FROM CUSTOMERS
WHERE SALARY LIKE &#39;200%&#39;;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/128507322961789663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/we-already-have-discussed-sql-like.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/128507322961789663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/128507322961789663'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/we-already-have-discussed-sql-like.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-7640511805605212659</id><published>2010-09-01T03:17:00.005-07:00</published><updated>2011-04-10T04:39:52.258-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A transaction is a unit of work that is performed against a database. Transactions are units or sequences of work accomplished in a logical order, whether in a manual fashion by a user or automatically by some sort of a database program.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A transaction is the propagation of one or more changes to the database. For example, if you are creating a record or updating a record or deleting a record from the table then you are performing transaction on the table. It is important to control transactions to ensure data integrity and to handle database errors.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Practically you will club many SQL queries into a group and you will execute all of them together as a part of a transaction.&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Properties of Transactions:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Transactions have the following four standard properties, usually referred to by the acronym ACID:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;Atomicity:&lt;/b&gt;&amp;nbsp;ensures that all operations within the work unit are completed successfully; otherwise, the transaction is aborted at the point of failure, and previous operations are rolled back to their former state.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;Consistency:&lt;/b&gt;&amp;nbsp;ensures that the database properly changes states upon a successfully committed transaction.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;Isolation:&lt;/b&gt;&amp;nbsp;enables transactions to operate independently of and transparent to each other.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;Durability:&lt;/b&gt;&amp;nbsp;ensures that the result or effect of a committed transaction persists in case of a system failure.&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Transaction Control:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;There are following commands used to control transactions:&lt;/div&gt;&lt;ol style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;COMMIT:&lt;/b&gt;&amp;nbsp;to save the changes.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;ROLLBACK:&lt;/b&gt;&amp;nbsp;to rollback the changes.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;SAVEPOINT:&lt;/b&gt;&amp;nbsp;creates points within groups of transactions in which to ROLLBACK&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;&lt;b&gt;SET TRANSACTION:&lt;/b&gt;&amp;nbsp;Places a name on a transaction.&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Transactional control commands are only used with the DML commands INSERT, UPDATE, and DELETE only. They can not be used while creating tables or dropping them because these operations are automatically commited in the database.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;The COMMIT Command:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The COMMIT command is the transactional command used to save changes invoked by a transaction to the database.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The COMMIT command saves all transactions to the database since the last COMMIT or ROLLBACK command.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The syntax for COMMIT command is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;COMMIT;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is the example which would delete records from the table having age = 25, and then COMMIT the changes in the database.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; DELETE FROM CUSTOMERS
     WHERE AGE = 25;
SQL&amp;gt; COMMIT;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;As a result, two rows from the table would be deleted and SELECT statement would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;The ROLLBACK Command:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The ROLLBACK command is the transactional command used to undo transactions that have not already been saved to the database.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The ROLLBACK command can only be used to undo transactions since the last COMMIT or ROLLBACK command was issued.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The syntax for ROLLBACK command is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ROLLBACK;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is the example which would delete records from the table having age = 25, and then ROLLBACK the changes in the database.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; DELETE FROM CUSTOMERS
     WHERE AGE = 25;
SQL&amp;gt; ROLLBACK;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;As a result, delete operation would not impact the table and SELECT statement would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;The SAVEPOINT Command:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A SAVEPOINT is a point in a transaction when you can roll the transaction back to a certain point without rolling back the entire transaction.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The syntax for SAVEPOINT command is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SAVEPOINT SAVEPOINT_NAME;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This command serves only in the creation of a SAVEPOINT among transactional statements. The ROLLBACK command is used to undo a group of transactions.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The syntax for rolling back to a SAVEPOINT is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ROLLBACK TO SAVEPOINT_NAME;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is an example where you plan to delete the three different records from the CUSTOMERS table. You want to create a SAVEPOINT before each delete, so that you can ROLLBACK to any SAVEPOINT at any time to return the appropriate data to its original state:&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now here is the series of operations:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SAVEPOINT SP1;
Savepoint created.
SQL&amp;gt; DELETE FROM CUSTOMERS WHERE ID=1;
1 row deleted.
SQL&amp;gt; SAVEPOINT SP2;
Savepoint created.
SQL&amp;gt; DELETE FROM CUSTOMERS WHERE ID=2;
1 row deleted.
SQL&amp;gt; SAVEPOINT SP3;
Savepoint created.
SQL&amp;gt; DELETE FROM CUSTOMERS WHERE ID=3;
1 row deleted.
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now that the three deletions have taken place, say you have changed your mind and decided to ROLLBACK to the SAVEPOINT that you identified as SP2. Because SP2 was created after the first deletion, the last two deletions are undone:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; ROLLBACK TO SP2;
Rollback complete.
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Notice that only the first deletion took place since you rolled back to SP2:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT * FROM CUSTOMERS;
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
6 rows selected.
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;The RELEASE SAVEPOINT Command:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The RELEASE SAVEPOINT command is used to remove a SAVEPOINT that you have created.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The syntax for RELEASE SAVEPOINT is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;RELEASE SAVEPOINT SAVEPOINT_NAME;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Once a SAVEPOINT has been released, you can no longer use the ROLLBACK command to undo transactions performed since the SAVEPOINT.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;The SET TRANSACTION Command:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The SET TRANSACTION command can be used to initiate a database transaction. This command is used to specify characteristics for the transaction that follows.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;For example, you can specify a transaction to be read only, or read write.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The syntax for SET TRANSACTION is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SET TRANSACTION [ READ WRITE | READ ONLY ];
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/7640511805605212659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/transaction-is-unit-of-work-that-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/7640511805605212659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/7640511805605212659'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/transaction-is-unit-of-work-that-is.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-5645650083462263316</id><published>2010-09-01T03:16:00.005-07:00</published><updated>2011-04-10T04:39:52.259-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A view is nothing more than a SQL statement that is stored in the database with an associated name. A view is actually a composition of a table in the form of a predefined SQL query.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A view can contain all rows of a table or select rows from a table. A view can be created from one or many tables which depends on the written SQL query to create a view.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Views which are kind of virtual tables, allow users to do the following:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Structure data in a way that users or classes of users find natural or intuitive.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Restrict access to the data such that a user can see and (sometimes) modify exactly what they need and no more.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Summarize data from various tables which can be used to generate reports.&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Creating Views:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Database views are created using the&amp;nbsp;&lt;b&gt;CREATE VIEW&lt;/b&gt;&amp;nbsp;statement. Views can be created from a single table, multiple tables, or another view.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;To create a view, a user must have the appropriate system privilege according to the specific implementation.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic CREATE VIEW syntax is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;CREATE VIEW view_name AS
SELECT column1, column2.....
FROM table_name
WHERE [condition];
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;You can include multiple tables in your SELECT statement in very similar way as you use them in normal SQL SELECT query.&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Example:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now, following is the example to create a view from CUSTOMERS table. This view would be used to have customer name and age from CUSTOMERS table:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL &amp;gt; CREATE VIEW CUSTOMERS_VIEW AS
SELECT name, age
FROM  CUSTOMERS;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now you can query CUSTOMERS_VIEW in similar way as you query an actual table. Following is the example:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL &amp;gt; SELECT * FROM CUSTOMERS_VIEW;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----------+-----+
| name     | age |
+----------+-----+
| Ramesh   |  32 |
| Khilan   |  25 |
| kaushik  |  23 |
| Chaitali |  25 |
| Hardik   |  27 |
| Komal    |  22 |
| Muffy    |  24 |
+----------+-----+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;The WITH CHECK OPTION:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The WITH CHECK OPTION is a CREATE VIEW statement option. The purpose of the WITH CHECK OPTION is to ensure that all UPDATE and INSERTs satisfy the condition(s) in the view definition.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;If they do not satisfy the condition(s), the UPDATE or INSERT returns an error.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The following is an example of creating same view CUSTOMERS_VIEW with the WITH CHECK OPTION:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;CREATE VIEW CUSTOMERS_VIEW AS
SELECT name, age
FROM  CUSTOMERS
WHERE age IS NOT NULL
WITH CHECK OPTION;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The WITH CHECK OPTION in this case should deny the entry of any NULL values in the view&#39;s AGE column, because the view is defined by data that does not have a NULL value in the AGE column.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Updating a View:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A view can be updated under certain conditions:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The SELECT clause may not contain the keyword DISTINCT.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The SELECT clause may not contain summary functions.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The SELECT clause may not contain set functions.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The SELECT clause may not contain set operators.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The SELECT clause may not contain an ORDER BY clause.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The FROM clause may not contain multiple tables.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The WHERE clause may not contain subqueries.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;The query may not contain GROUP BY or HAVING.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Calculated columns may not be updated.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;All NOT NULL columns from the base table must be included in the view in order for the INSERT query to function.&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;So if a view satisties all the above mentioned rules then you can update a view. Following is an example to update the age of Ramesh:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL &amp;gt; UPDATE CUSTOMERS_VIEW
      SET AGE = 35
      WHERE name=&#39;Ramesh&#39;;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would ultimately update the base table CUSTOMERS and same would reflect in the view itself. Now try to query base table, and SELECT statement would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  35 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Inserting Rows into a View:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Rows of data can be inserted into a view. The same rules that apply to the UPDATE command also apply to the INSERT command.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Here we can not insert rows in CUSTOMERS_VIEW because we have not included all the NOT NULL columns in this view, otherwise you can insert rows in a view in similar way as you insert them in a table.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Deleting Rows into a View:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Rows of data can be deleted from a view. The same rules that apply to the UPDATE and INSERT commands apply to the DELETE command.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is an example to delete a record having AGE= 22.&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL &amp;gt; DELETE FROM CUSTOMERS_VIEW
      WHERE age = 22;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would ultimately delete a row from the base table CUSTOMERS and same would reflect in the view itself. Now try to query base table, and SELECT statement would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  35 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Dropping Views:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Obviously, where you have a view, you need a way to drop the view if it is no longer needed. The syntax is very simple as given below:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;DROP VIEW view_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is an example to drop CUSTOMERS_VIEW from CUSTOMERS table:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;DROP VIEW CUSTOMERS_VIEW;
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/5645650083462263316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/view-is-nothing-more-than-sql-statement.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/5645650083462263316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/5645650083462263316'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/view-is-nothing-more-than-sql-statement.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-3707465018107477562</id><published>2010-09-01T03:16:00.001-07:00</published><updated>2011-04-10T04:39:52.259-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The SQL&amp;nbsp;&lt;b&gt;TRUNCATE TABLE&lt;/b&gt;&amp;nbsp;command is used to delete complete data from an existing table.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;You can also use DROP TABLE command to delete complete table but it would remove complete table structure form the database and you would need to re-create this table once again if you wish you store some data.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of&amp;nbsp;&lt;b&gt;TRUNCATE TABLE&lt;/b&gt;&amp;nbsp;is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;TRUNCATE TABLE  table_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is the example to turncate:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL &amp;gt; TRUNCATE TABLE CUSTOMERS;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now CUSTOMERS table is truncated and following would be output from SELECT statement:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT * FROM CUSTOMERS;
Empty set (0.00 sec)

&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/3707465018107477562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-truncate-table-is-used-to-delete.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/3707465018107477562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/3707465018107477562'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-truncate-table-is-used-to-delete.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-1732824782243971930</id><published>2010-09-01T03:15:00.007-07:00</published><updated>2011-04-10T04:39:52.259-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The SQL&amp;nbsp;&lt;b&gt;ALTER TABLE&lt;/b&gt;&amp;nbsp;command is used to add, delete, or modify columns in an existing table.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;You would also use ALTER TABLE command to add and drop various constraints on a an existing table.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of&amp;nbsp;&lt;b&gt;ALTER TABLE&lt;/b&gt;&amp;nbsp;to add a new column in an existing table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name ADD column_name datatype;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of ALTER TABLE to&amp;nbsp;&lt;b&gt;DROP COLUMN&lt;/b&gt;&amp;nbsp;in an existing table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name DROP COLUMN column_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of ALTER TABLE to change the&amp;nbsp;&lt;b&gt;DATA TYPE&lt;/b&gt;&amp;nbsp;of a column in a table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name ALTER COLUMN column_name datatype;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of ALTER TABLE to add a&amp;nbsp;&lt;b&gt;NOT NULL&lt;/b&gt;&amp;nbsp;constraint to a column in a table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name MODIFY column_name datatype NOT NULL;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of ALTER TABLE to&amp;nbsp;&lt;b&gt;ADD UNIQUE CONSTRAINT&lt;/b&gt;&amp;nbsp;to a table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name 
ADD CONSTRAINT MyUniqueConstraint UNIQUE(column1, column2...);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of ALTER TABLE to&amp;nbsp;&lt;b&gt;ADD CHECK CONSTRAINT&lt;/b&gt;&amp;nbsp;to a table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name 
ADD CONSTRAINT MyUniqueConstraint CHECK (CONDITION);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of ALTER TABLE to&amp;nbsp;&lt;b&gt;ADD PRIMARY KEY&lt;/b&gt;&amp;nbsp;constraint to a table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name 
ADD CONSTRAINT MyPrimaryKey PRIMARY KEY (column1, column2...);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of ALTER TABLE to&amp;nbsp;&lt;b&gt;DROP CONSTRAINT&lt;/b&gt;&amp;nbsp;from a table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name 
DROP CONSTRAINT MyUniqueConstraint;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;If you&#39;re using MySQL, the code is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name 
DROP INDEX MyUniqueConstraint;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of ALTER TABLE to&amp;nbsp;&lt;b&gt;DROP PRIMARY KEY&lt;/b&gt;&amp;nbsp;constraint from a table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name 
DROP CONSTRAINT MyPrimaryKey;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;If you&#39;re using MySQL, the code is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name 
DROP PRIMARY KEY;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is the example to ADD a new column in an existing table:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE CUSTOMERS ADD SEX char(1);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now CUSTOMERS table is changed and following would be output from SELECT statement:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+---------+-----+-----------+----------+------+
| ID | NAME    | AGE | ADDRESS   | SALARY   | SEX  |
+----+---------+-----+-----------+----------+------+
|  1 | Ramesh  |  32 | Ahmedabad |  2000.00 | NULL |
|  2 | Ramesh  |  25 | Delhi     |  1500.00 | NULL |
|  3 | kaushik |  23 | Kota      |  2000.00 | NULL |
|  4 | kaushik |  25 | Mumbai    |  6500.00 | NULL |
|  5 | Hardik  |  27 | Bhopal    |  8500.00 | NULL |
|  6 | Komal   |  22 | MP        |  4500.00 | NULL |
|  7 | Muffy   |  24 | Indore    | 10000.00 | NULL |
+----+---------+-----+-----------+----------+------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is the example to DROP sex column from existing table:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE CUSTOMERS DROP SEX;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now CUSTOMERS table is changed and following would be output from SELECT statement:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+---------+-----+-----------+----------+
| ID | NAME    | AGE | ADDRESS   | SALARY   |
+----+---------+-----+-----------+----------+
|  1 | Ramesh  |  32 | Ahmedabad |  2000.00 |
|  2 | Ramesh  |  25 | Delhi     |  1500.00 |
|  3 | kaushik |  23 | Kota      |  2000.00 |
|  4 | kaushik |  25 | Mumbai    |  6500.00 |
|  5 | Hardik  |  27 | Bhopal    |  8500.00 |
|  6 | Komal   |  22 | MP        |  4500.00 |
|  7 | Muffy   |  24 | Indore    | 10000.00 |
+----+---------+-----+-----------+----------+
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/1732824782243971930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-alter-table-is-used-to-add-delete.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/1732824782243971930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/1732824782243971930'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-alter-table-is-used-to-add-delete.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-6067330316126204051</id><published>2010-09-01T03:15:00.003-07:00</published><updated>2011-04-10T04:39:52.259-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Indexes are special lookup tables that the database search engine can use to speed up data retrieval. Simply put, an index is a pointer to data in a table. An index in a database is very similar to an index in the back of a book.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;For example, if you want to reference all pages in a book that discuss a certain topic, you first refer to the index, which lists all topics alphabetically, and are then referred to one or more specific page numbers.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;An index helps speed up SELECT queries and WHERE clauses, but it slows down data input, with UPDATE and INSERT statements. Indexes can be created or dropped with no effect on the data.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Creating an index involves the CREATE INDEX statement, which allows you to name the index, to specify the table and which column or columns to index, and to indicate whether the index is in ascending or descending order.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Indexes can also be unique, similar to the UNIQUE constraint, in that the index prevents duplicate entries in the column or combination of columns on which there&#39;s an index.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;The CREATE INDEX Command:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of&amp;nbsp;&lt;b&gt;CREATE INDEX&lt;/b&gt;&amp;nbsp;is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;CREATE INDEX index_name ON table_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Single-Column Indexes:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A single-column index is one that is created based on only one table column. The basic syntax is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;CREATE INDEX index_name
ON table_name (column_name);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Unique Indexes:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Unique indexes are used not only for performance, but also for data integrity. A unique index does not allow any duplicate values to be inserted into the table. The basic syntax is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;CREATE INDEX index_name
on table_name (column_name);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Composite Indexes:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A composite index is an index on two or more columns of a table. The basic syntax is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;CREATE INDEX index_name
on table_name (column1, column2);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Whether to create a single-column index or a composite index, take into consideration the column(s) that you may use very frequently in a query&#39;s WHERE clause as filter conditions.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Should there be only one column used, a single-column index should be the choice. Should there be two or more columns that are frequently used in the WHERE clause as filters, the composite index would be the best choice.&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px; text-align: justify;&quot;&gt;Implicit Indexes:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Implicit indexes are indexes that are automatically created by the database server when an object is created. Indexes are automatically created for primary key constraints and unique constraints.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;The DROP INDEX Command:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;An index can be dropped using SQL&amp;nbsp;&lt;b&gt;DROP&lt;/b&gt;&amp;nbsp;command. Care should be taken when dropping an index because performance may be slowed or improved.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;DROP INDEX index_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;When should indexes be avoided?&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Although indexes are intended to enhance a database&#39;s performance, there are times when they should be avoided. The following guidelines indicate when the use of an index should be reconsidered:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Indexes should not be used on small tables.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Tables that have frequent, large batch update or insert operations.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Indexes should not be used on columns that contain a high number of NULL values.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;Columns that are frequently manipulated should not be indexed.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/6067330316126204051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/indexes-are-special-lookup-tables-that.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/6067330316126204051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/6067330316126204051'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/indexes-are-special-lookup-tables-that.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-8355473771241756495</id><published>2010-09-01T03:15:00.001-07:00</published><updated>2011-04-10T04:39:52.260-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;You can rename a table or a column temporarily by giving another name known as alias.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The use of table aliases means to rename a table in a particular SQL statement. The renaming is a temporary change and the actual table name does not change in the database.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The column aliases are used to rename a table&#39;s columns for the purpose of a particular SQL query.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of&amp;nbsp;&lt;b&gt;table&lt;/b&gt;&amp;nbsp;alias is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1, column2....
FROM table_name AS alias_name
WHERE [condition];
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of&amp;nbsp;&lt;b&gt;column&lt;/b&gt;&amp;nbsp;alias is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column_name AS alias_name
FROM table_name
WHERE [condition];
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider following two tables, (a) CUSTOMERS table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;(b) Another table is ORDERS as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+-----+---------------------+-------------+--------+
|OID  | DATE                | CUSTOMER_ID | AMOUNT |
+-----+---------------------+-------------+--------+
| 102 | 2009-10-08 00:00:00 |           3 |   3000 |
| 100 | 2009-10-08 00:00:00 |           3 |   1500 |
| 101 | 2009-11-20 00:00:00 |           2 |   1560 |
| 103 | 2008-05-20 00:00:00 |           4 |   2060 |
+-----+---------------------+-------------+--------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now following is the usage of&amp;nbsp;&lt;b&gt;table alias&lt;/b&gt;:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT C.ID, C.NAME, C.AGE, O.AMOUNT 
        FROM CUSTOMERS AS C, ORDERS AS O
        WHERE  C.ID = O.CUSTOMER_ID;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+---------+-----+--------+
| ID | NAME    | AGE | AMOUNT |
+----+---------+-----+--------+
|  3 | kaushik |  23 |   3000 |
|  3 | kaushik |  23 |   1500 |
|  2 | Ramesh  |  25 |   1560 |
|  4 | kaushik |  25 |   2060 |
+----+---------+-----+--------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is the usage of&amp;nbsp;&lt;b&gt;column alias&lt;/b&gt;:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT  ID AS CUSTOMER_ID, NAME AS CUSTOMER_NAME
     FROM CUSTOMERS
     WHERE SALARY IS NOT NULL;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+-------------+---------------+
| CUSTOMER_ID | CUSTOMER_NAME |
+-------------+---------------+
|           1 | Ramesh        |
|           2 | Ramesh        |
|           3 | kaushik       |
|           4 | kaushik       |
|           5 | Hardik        |
|           6 | Komal         |
|           7 | Muffy         |
+-------------+---------------+
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/8355473771241756495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/you-can-rename-table-or-column.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/8355473771241756495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/8355473771241756495'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/you-can-rename-table-or-column.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-4082940899327582771</id><published>2010-09-01T03:14:00.001-07:00</published><updated>2011-04-10T04:39:52.260-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The SQL&amp;nbsp;&lt;b&gt;NULL&lt;/b&gt;&amp;nbsp;is the term used to represent a missing value. A NULL value in a table is a value in a field that appears to be blank.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A field with a NULL value is a field with no value. It is very important to understand that a NULL value is different than a zero value or a field that contains spaces.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of&amp;nbsp;&lt;b&gt;NULL&lt;/b&gt;&amp;nbsp;while creating a table:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; CREATE TABLE CUSTOMERS(
   ID   INT              NOT NULL,
   NAME VARCHAR (20)     NOT NULL,
   AGE  INT              NOT NULL,
   ADDRESS  CHAR (25) ,
   SALARY   DECIMAL (18, 2),       
   PRIMARY KEY (ID)
);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Here&amp;nbsp;&lt;b&gt;NOT NULL&lt;/b&gt;&amp;nbsp;signifies that column should always accept an explicit value of the given data type. There are two column where we did not use NOT NULL which means these column could be NULL.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;A field with a NULL value is one that has been left blank during record creation.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The NULL value can cause problems when selecting data, however, because when comparing an unknown value to any other value, the result is always unknown and not included in the final results.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;You must use the&amp;nbsp;&lt;b&gt;IS NULL&lt;/b&gt;&amp;nbsp;or&amp;nbsp;&lt;b&gt;IS NOT NULL&lt;/b&gt;&amp;nbsp;operators in order to check for a NULL value.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider following table, CUSTOMERS having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |          |
|  7 | Muffy    |  24 | Indore    |          |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now following is the usage of&amp;nbsp;&lt;b&gt;IS NOT NULL&lt;/b&gt;&amp;nbsp;operator:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT  ID, NAME, AGE, ADDRESS, SALARY
     FROM CUSTOMERS
     WHERE SALARY IS NOT NULL;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now following is the usage of&amp;nbsp;&lt;b&gt;IS NULL&lt;/b&gt;&amp;nbsp;operator:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT  ID, NAME, AGE, ADDRESS, SALARY
     FROM CUSTOMERS
     WHERE SALARY IS NULL;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  6 | Komal    |  22 | MP        |          |
|  7 | Muffy    |  24 | Indore    |          |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/4082940899327582771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-null-term-used-to-represent-missing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/4082940899327582771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/4082940899327582771'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-null-term-used-to-represent-missing.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-3082558196175337840</id><published>2010-09-01T03:13:00.002-07:00</published><updated>2011-04-10T04:39:52.260-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The SQL&amp;nbsp;&lt;b&gt;UNION&lt;/b&gt;&amp;nbsp;clause/operator is used to combine the results of two or more SELECT statements without returning any duplicate rows.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;To use UNION, each SELECT must have the same number of columns selected, the same number of column expressions, the same data type, and have them in the same order but they do not have to be the same length.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of&amp;nbsp;&lt;b&gt;UNION&lt;/b&gt;&amp;nbsp;is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]

UNION

SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Here given condition could be any given expression based on your requirement.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider following two tables, (a) CUSTOMERS table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;(b) Another table is ORDERS as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+-----+---------------------+-------------+--------+
|OID  | DATE                | CUSTOMER_ID | AMOUNT |
+-----+---------------------+-------------+--------+
| 102 | 2009-10-08 00:00:00 |           3 |   3000 |
| 100 | 2009-10-08 00:00:00 |           3 |   1500 |
| 101 | 2009-11-20 00:00:00 |           2 |   1560 |
| 103 | 2008-05-20 00:00:00 |           4 |   2060 |
+-----+---------------------+-------------+--------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now let us join these two tables in our SELECT statement as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT  ID, NAME, AMOUNT, DATE
     FROM CUSTOMERS
     LEFT JOIN ORDERS
     ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID
UNION
     SELECT  ID, NAME, AMOUNT, DATE
     FROM CUSTOMERS
     RIGHT JOIN ORDERS
     ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+------+---------+--------+---------------------+
| ID   | NAME    | AMOUNT | DATE                |
+------+---------+--------+---------------------+
|    3 | kaushik |   3000 | 2009-10-08 00:00:00 |
|    3 | kaushik |   1500 | 2009-10-08 00:00:00 |
|    2 | Ramesh  |   1560 | 2009-11-20 00:00:00 |
|    4 | kaushik |   2060 | 2008-05-20 00:00:00 |
|    1 | Ramesh  |   NULL | NULL                |
|    5 | Hardik  |   NULL | NULL                |
|    6 | Komal   |   NULL | NULL                |
|    7 | Muffy   |   NULL | NULL                |
+------+---------+--------+---------------------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;The UNION ALL Clause:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The UNION ALL operator is used to combine the results of two SELECT statements including duplicate rows.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The same rules that apply to UNION apply to the UNION ALL operator.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of&amp;nbsp;&lt;b&gt;UNION ALL&lt;/b&gt;&amp;nbsp;is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]

UNION ALL

SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Here given condition could be any given expression based on your requirement.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider following two tables, (a) CUSTOMERS table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;(b) Another table is ORDERS as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+-----+---------------------+-------------+--------+
|OID  | DATE                | CUSTOMER_ID | AMOUNT |
+-----+---------------------+-------------+--------+
| 102 | 2009-10-08 00:00:00 |           3 |   3000 |
| 100 | 2009-10-08 00:00:00 |           3 |   1500 |
| 101 | 2009-11-20 00:00:00 |           2 |   1560 |
| 103 | 2008-05-20 00:00:00 |           4 |   2060 |
+-----+---------------------+-------------+--------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now let us join these two tables in our SELECT statement as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT  ID, NAME, AMOUNT, DATE
     FROM CUSTOMERS
     LEFT JOIN ORDERS
     ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID
UNION
     SELECT  ID, NAME, AMOUNT, DATE
     FROM CUSTOMERS
     RIGHT JOIN ORDERS
     ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+------+---------+--------+---------------------+
| ID   | NAME    | AMOUNT | DATE                |
+------+---------+--------+---------------------+
|    3 | kaushik |   3000 | 2009-10-08 00:00:00 |
|    3 | kaushik |   1500 | 2009-10-08 00:00:00 |
|    2 | Ramesh  |   1560 | 2009-11-20 00:00:00 |
|    4 | kaushik |   2060 | 2008-05-20 00:00:00 |
|    1 | Ramesh  |   NULL | NULL                |
|    2 | Ramesh  |   1560 | 2009-11-20 00:00:00 |
|    3 | kaushik |   3000 | 2009-10-08 00:00:00 |
|    3 | kaushik |   1500 | 2009-10-08 00:00:00 |
|    4 | kaushik |   2060 | 2008-05-20 00:00:00 |
|    5 | Hardik  |   NULL | NULL                |
|    6 | Komal   |   NULL | NULL                |
|    7 | Muffy   |   NULL | NULL                |
+------+---------+--------+---------------------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;There are two other clauses (i.e operators ) which are very similar to UNION clause:&lt;/div&gt;&lt;ol style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;SQL&amp;nbsp;INTERSECT Clause: is used to combine two SELECT statements, but returns rows only from the first SELECT statement that are identical to a row in the second SELECT statement.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;SQL&amp;nbsp;EXCEPT Clause&amp;nbsp;: combines two SELECT statements and returns rows from the first SELECT statement that are not returned by the second SELECT statement.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/3082558196175337840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-union-is-used-to-combine-results-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/3082558196175337840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/3082558196175337840'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-union-is-used-to-combine-results-of.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-4731721277750178216</id><published>2010-09-01T03:13:00.000-07:00</published><updated>2011-04-10T04:39:52.261-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The SQL&amp;nbsp;&lt;b&gt;Joins&lt;/b&gt;&amp;nbsp;clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider following two tables, (a) CUSTOMERS table is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;(b) Another table is ORDERS as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+-----+---------------------+-------------+--------+
|OID  | DATE                | CUSTOMER_ID | AMOUNT |
+-----+---------------------+-------------+--------+
| 102 | 2009-10-08 00:00:00 |           3 |   3000 |
| 100 | 2009-10-08 00:00:00 |           3 |   1500 |
| 101 | 2009-11-20 00:00:00 |           2 |   1560 |
| 103 | 2008-05-20 00:00:00 |           4 |   2060 |
+-----+---------------------+-------------+--------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Now let us join these two tables in our SELECT statement as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT ID, NAME, AGE, AMOUNT, 
        FROM CUSTOMERS, ORDERS
        WHERE  CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+---------+-----+--------+
| ID | NAME    | AGE | AMOUNT |
+----+---------+-----+--------+
|  3 | kaushik |  23 |   3000 |
|  3 | kaushik |  23 |   1500 |
|  2 | Ramesh  |  25 |   1560 |
|  4 | kaushik |  25 |   2060 |
+----+---------+-----+--------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Here it is noteable that the join is performed in the WHERE clause. Several operators can be used to join tables, such as =, &amp;lt;, &amp;gt;, &amp;lt;&amp;gt;, &amp;lt;=, &amp;gt;=, !=, BETWEEN, LIKE, and NOT; they can all be used to join tables. However, the most common operator is the equal symbol.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;SQL Join Types:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;There are different type of joins available in SQL:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;INNER JOIN:&amp;nbsp;returns rows when there is a match in both tables.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;LEFT JOIN:&amp;nbsp;returns all rows from the left table, even if there are no matches in the right table.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;RIGHT JOIN:&amp;nbsp;returns all rows from the right table, even if there are no matches in the left table.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;FULL JOIN:&amp;nbsp;returns rows when there is a match in one of the tables.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;SELF JOIN:&amp;nbsp;is used to join a table to itself, as if the table were two tables, temporarily renaming at least one table in the SQL statement.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;CARTESIAN JOIN:&amp;nbsp;returns the cartesian product of the sets of records from the two or more joined tables.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/4731721277750178216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-joins-is-used-to-combine-records.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/4731721277750178216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/4731721277750178216'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-joins-is-used-to-combine-records.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-1841547804009030110</id><published>2010-09-01T03:12:00.001-07:00</published><updated>2011-04-10T04:39:52.261-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Constraints are the rules enforced on data columns on table. These are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the database.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Contraints could be column level or table level. Column level constraints are applied only to one column where as table level constraints are applied to the whole table.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;NOT NULL Constraint: Ensures that a column cannot have NULL value.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;DEFAULT Constraint&amp;nbsp;: Provides a default value for a column when none is specified.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;UNIQUE Constraint: Ensures that all values in a column are different.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;PRIMARY Key: Uniquely identified each rows/records in a database table.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;FOREIGN Key: Uniquely identified a rows/records in any another database table.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;CHECK Constraint: The CHECK constraint ensures that all values in a column satisfy certain conditions.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: justify;&quot;&gt;INDEX: Use to create and retrieve data from the database very quickly.&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Constraints can be specified when a table is created with the CREATE TABLE statement or you can use ALTER TABLE statment to create constraints even after the table is created.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Dropping Constraints:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Any constraint that you have defined can be dropped using the ALTER TABLE command with the DROP CONSTRAINT option.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;For example, to drop the primary key constraint in the EMPLOYEES table, you can use the following command:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE EMPLOYEES DROP CONSTRAINT EMPLOYEES_PK;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Some implementations may provide shortcuts for dropping certain constraints. For example, to drop the primary key constraint for a table in Oracle, you can use the following command:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE EMPLOYEES DROP PRIMARY KEY;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Some implementations allow you to disable constraints. Instead of permanently dropping a constraint from the database, you may want to temporarily disable the constraint, and then enable it later.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Integrity Constraints:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Integrity constraints are used to ensure accuracy and consistency of data in a relational database. Data integrity is handled in a relational database through the concept of referential integrity.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;There are many types of integrity constraints that play a role in referential integrity (RI). These constraints include Primary Key, Foreign Key, Unique Constraints and other constraints mentioned above.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/1841547804009030110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/constraints-are-rules-enforced-on-data.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/1841547804009030110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/1841547804009030110'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/constraints-are-rules-enforced-on-data.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-2637731241897451006</id><published>2010-09-01T03:11:00.000-07:00</published><updated>2011-04-10T04:39:52.261-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;What is SQL?&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;SQL is structured Query Language which is a computer language for storing, manipulating and retrieving data stored in relational database.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;SQL is the standard language for Relation Database System. All relational database management systems like MySQL, MS Access, Oracle, Sybase, Informix, postgres and SQL Server uses SQL as standard database language.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Also they are using different dialects, Such as:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;MS SQL Server using T-SQL,&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Oracle using PL/SQL,&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;MS Access version of SQL is called JET SQL (native format )etc&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;Why SQL?&lt;/h1&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Allow users to access data in relational database management systems.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Allow users to describe the data.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Allow users to define the data in database and manipulate that data.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Allow to embed within other languages using SQL modules, libraries &amp;amp; pre-compilers.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Allow users to create and drop databases and tables.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Allow users to create view, stored procedure, functions in a database.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Allow users to set permissions on tables, procedures, and views&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;What is RDBMS?&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;RDBMS stands for&amp;nbsp;&lt;b&gt;&lt;u&gt;R&lt;/u&gt;&lt;/b&gt;elational&amp;nbsp;&lt;b&gt;&lt;u&gt;D&lt;/u&gt;&lt;/b&gt;atabase&amp;nbsp;&lt;b&gt;&lt;u&gt;M&lt;/u&gt;&lt;/b&gt;anagement&amp;nbsp;&lt;b&gt;&lt;u&gt;S&lt;/u&gt;&lt;/b&gt;ystem. RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;A Relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;What is table ?&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;The data in RDBMS is stored in database objects called&amp;nbsp;&lt;b&gt;tables&lt;/b&gt;. The table is a collection of related data entries and it consists of columns and rows.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Remember, a table is the most common and simplest form of data storage in a relational database.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;What is field?&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Every table is broken up into smaller entities called fields. The fields in the CUSTOMERS table consist of ID, NAME, AGE, ADDRESS and SALARY.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;A field is a column in a table that is designed to maintain specific information about every record in the table.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;What is record, or row?&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;A record, also called a row of data, is each individual entry that exists in a table. For example there are 7 records in the above CUSTOMERS table.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;A record is a horizontal entity in a table.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;What is column?&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;A column is a vertical entity in a table that contains all information associated with a specific field in a table.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;What is NULL value?&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;A NULL value in a table is a value in a field that appears to be blank which means A field with a NULL value is a field with no value.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;It is very important to understand that a NULL value is different than a zero value or a field that contains spaces. A field with a NULL value is one that has been left blank during record creation.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;SQL Constraints:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Constraints are the rules enforced on data columns on table. These are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the database.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Contraints could be column level or table level. Column level constraints are applied only to one column where as table level constraints are applied to the whole table.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;SQL Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;SQL is followed by unique set of rules and guidelines called Syntax. This tutorial gives you a quick start with SQL by listing all the basic SQL Syntax:&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;All the SQL statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;).&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Important point to be noted is that SQL is&amp;nbsp;&lt;b&gt;case insensitive&lt;/b&gt;&amp;nbsp;which means SELECT and select have same meaning in SQL statements but MySQL make difference in table names. So if you are working with MySQL then you need to give table names as they exist in the database.&lt;/div&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL SELECT Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1, column2....columnN
FROM   table_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL DISTINCT Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT DISTINCT column1, column2....columnN
FROM   table_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL WHERE Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL AND/OR Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION-1 {AND|OR} CONDITION-2;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL IN Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name IN (val-1, val-2,...val-N);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL BETWEEN Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name BETWEEN val-1 AND val-2;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL Like Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name LIKE { PATTERN };
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL ORDER BY Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION
ORDER BY column_name {ASC|DESC};
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL GROUP BY Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL COUNT Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT COUNT(column_name)
FROM   table_name
WHERE  CONDITION;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL HAVING Clause:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name
HAVING (arithematic function condition);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL CREATE TABLE Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns )
);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL DROP TABLE Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;DROP TABLE table_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL CREATE INDEX Statement :&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;CREATE UNIQUE INDEX index_name
ON table_name ( column1, column2,...columnN);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL DROP INDEX Statement :&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name
DROP INDEX index_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL DESC Statement :&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;DESC table_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL TRUNCATE TABLE Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;TRUNCATE TABLE table_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL ALTER TABLE Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL ALTER TABLE Statement (Rename) :&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ALTER TABLE table_name RENAME TO new_table_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL INSERT INTO Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;INSERT INTO table_name( column1, column2....columnN)
VALUES ( value1, value2....valueN);
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL UPDATE Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;UPDATE table_name
SET column1 = value1, column2 = value2....columnN=valueN
[ WHERE  CONDITION ];
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL DELETE Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;DELETE FROM table_name
WHERE  {CONDITION};
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL CREATE DATABASE Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;CREATE DATABASE database_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL DROP DATABASE Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;DROP DATABASE database_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL USE Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;USE DATABASE database_name;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL COMMIT Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;COMMIT;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL ROLLBACK Statement:&lt;/h2&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;ROLLBACK;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;SQL - Operators:&lt;/h1&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL Arithmetic Operators:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Assume variable a holds 10 and variable b holds 20 then:&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;10%&quot;&gt;Operator&lt;/th&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;45%&quot;&gt;Description&lt;/th&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Example&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;+&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Addition - Adds values on either side of the operator&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;a + b will give 30&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;-&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Subtraction - Subtracts right hand operand from left hand operand&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;a - b will give -10&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;*&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Multiplication - Multiplies values on either side of the operator&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;a * b will give 200&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;/&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Division - Divides left hand operand by right hand operand&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;b / a will give 2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;%&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Modulus - Divides left hand operand by right hand operand and returns remainder&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;b % a will give 0&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL Comparison Operators:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Assume variable a holds 10 and variable b holds 20 then:&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;10%&quot;&gt;Operator&lt;/th&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;45%&quot;&gt;Description&lt;/th&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;Example&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;=&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Checks if the value of two operands are equal or not, if yes then condition becomes true.&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;(a = b) is not true.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;!=&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;(a != b) is true.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&amp;lt;&amp;gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;(a &amp;lt;&amp;gt; b) is true.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&amp;gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;(a &amp;gt; b) is not true.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&amp;lt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;(a &amp;lt; b) is true.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&amp;gt;=&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;(a &amp;gt;= b) is not true.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&amp;lt;=&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;(a &amp;lt;= b) is true.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;!&amp;lt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Checks if the value of left operand is not less than the value of right operand, if yes then condition becomes true.&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;(a !&amp;lt; b) is false.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;!&amp;gt;&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;Checks if the value of left operand is not greater than the value of right operand, if yes then condition becomes true.&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;(a !&amp;gt; b) is true.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h2 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; margin-bottom: 10px; margin-top: 10px;&quot;&gt;SQL Logical Operators:&lt;/h2&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;Here is a list of all the logical operators available in SQL.&lt;/div&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;20%&quot;&gt;Operator&lt;/th&gt;&lt;th style=&quot;background-color: #cdcdcd; font-family: verdana, helvetica, arial, sans-serif;&quot; width=&quot;80%&quot;&gt;Description&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;ALL&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The ALL operator is used to compare a value to all values in another value set.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;AND&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The AND operator allows the existence of multiple conditions in an SQL statement&#39;s WHERE clause.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;ANY&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The ANY operator is used to compare a value to any applicable value in the list according to the condition.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;BETWEEN&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The BETWEEN operator is used to search for values that are within a set of values, given the minimum value and the maximum value.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;EXISTS&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The EXISTS operator is used to search for the presence of a row in a specified table that meets certain criteria.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;IN&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The IN operator is used to compare a value to a list of literal values that have been specified.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;LIKE&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The LIKE operator is used to compare a value to similar values using wildcard operators.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;NOT&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The NOT operator reverses the meaning of the logical operator with which it is used. Eg. NOT EXISTS, NOT BETWEEN, NOT IN etc.&amp;nbsp;&lt;b&gt;This is negate operator.&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;OR&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The OR operator is used to combine multiple conditions in an SQL statement&#39;s WHERE clause.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;IS NULL&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The NULL operator is used to compare a value with a NULL value.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;UNIQUE&lt;/td&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;The UNIQUE operator searches every row of a specified table for uniqueness (no duplicates).&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px;&quot;&gt;SQL - Useful Functions:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;SQL has many built-in functions for performing processing on string or numeric data. Following is the list of all useful SQL built-in functions:&lt;/div&gt;&lt;ul style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL COUNT Function&amp;nbsp;- The SQL COUNT aggregate function is used to count the number of rows in a database table.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL MAX Function&amp;nbsp;- The SQL MAX aggregate function allows us to select the highest (maximum) value for a certain column.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL MIN Function&amp;nbsp;- The SQL MIN aggregate function allows us to select the lowest (minimum) value for a certain column.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL AVG Function&amp;nbsp;- The SQL AVG aggregate function selects the average value for certain table column.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL SUM Function&amp;nbsp;- The SQL SUM aggregate function allows selecting the total for a numeric column.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL SQRT Functions&amp;nbsp;- This is used to generate a square root of a given number.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL RAND Function&amp;nbsp;- This is used to generate a random number using SQL command.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL CONCAT Function&amp;nbsp;- This is used to concatenate any string inside any SQL command.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL Numeric Functions&amp;nbsp;- Complete list of SQL functions required to manipulate numbers in SQL.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif;&quot;&gt;SQL String Functions&amp;nbsp;- Complete list of SQL functions required to manipulate strings in SQL.&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/2637731241897451006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/what-is-sql-sql-is-structured-query.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/2637731241897451006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/2637731241897451006'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/what-is-sql-sql-is-structured-query.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1039465040462573013.post-426969139538622529</id><published>2010-09-01T03:09:00.005-07:00</published><updated>2011-04-10T04:39:52.262-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL"/><title type='text'></title><content type='html'>&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The SQL&amp;nbsp;&lt;b&gt;ORDER BY&lt;/b&gt;&amp;nbsp;clause is used to sort the data in ascending or descending order, based on one or more columns. Some database sorts query results in ascending order by default.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Syntax:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;The basic syntax of ORDER BY clause which would be used to sort result in ascending or descending order is as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SELECT column-list 
FROM table_name 
[WHERE condition] 
[ORDER BY column1, column2, .. columnN] [ASC | DESC];
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;You can use more than one column in the ORDER BY clause. Make sure whatever column you are using to sort, that column should be in column-list.&lt;/div&gt;&lt;h1 style=&quot;background-color: transparent; color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 18px; text-align: justify;&quot;&gt;Example:&lt;/h1&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Consider CUSTOMERS table is having following records:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is an example which would sort the result in ascending order by NAME and SALARY:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT * FROM CUSTOMERS
     ORDER BY NAME, SALARY;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;Following is an example which would sort the result in descending order by NAME:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT * FROM CUSTOMERS
     ORDER BY NAME DESC;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;To fetch the rows with own preferred order, the SELECT query would as follows:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;SQL&amp;gt; SELECT * FROM CUSTOMERS
    ORDER BY (CASE ADDRESS
    WHEN &#39;DELHI&#39;   THEN 1
    WHEN &#39;BHOPAL&#39;   THEN 2
    WHEN &#39;KOTA&#39;   THEN 3
    WHEN &#39;AHMADABAD&#39; THEN 4
    WHEN &#39;MP&#39;  THEN 5
    ELSE 100 END) ASC, ADDRESS DESC;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This would produce following result:&lt;/div&gt;&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;5&quot; class=&quot;src&quot; style=&quot;background-color: #f1f1f1; border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-family: verdana, helvetica, arial, sans-serif; font-size: 11px; padding-left: 5px; text-align: justify; width: 462px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;font-family: verdana, helvetica, arial, sans-serif; text-align: left;&quot;&gt;&lt;pre style=&quot;font-family: &#39;Courier New&#39;, monospace; font-size: 12px; margin-bottom: 0px; margin-left: 0px;&quot;&gt;+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
+----+----------+-----+-----------+----------+
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;font-family: verdana, helvetica, arial, sans-serif; font-size: 9.16667px; text-align: justify;&quot;&gt;This will sort customers by ADDRESS in your ownoOrder of preference first and in a natural order for the remaining addresses. Also remaining Addresses will be sorted in the reverse alpha order.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wlanguages15.blogspot.com/feeds/426969139538622529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-order-by-is-used-to-sort-data-in_01.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/426969139538622529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1039465040462573013/posts/default/426969139538622529'/><link rel='alternate' type='text/html' href='http://wlanguages15.blogspot.com/2010/09/sql-order-by-is-used-to-sort-data-in_01.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>