<?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-316532415128145912</id><updated>2024-10-04T18:57:13.999-07:00</updated><category term="Data Types"/><category term="SQL Server"/><category term="Select"/><category term="Table"/><category term="Create"/><category term="Date Types"/><category term="Number Types"/><category term="Binary"/><category term="Calculate"/><category term="Character Strings"/><category term="Columns"/><category term="Connect"/><category term="Data"/><category term="Database"/><category term="Date"/><category term="Disconnect"/><category term="Install"/><category term="Load Data"/><category term="NULL"/><category term="Operatyng System"/><category term="Other Types"/><category term="Particular"/><category term="Pattern"/><category term="Prompt"/><category term="Queries"/><category term="Retiriev"/><category term="Rows"/><category term="Server"/><category term="Sort"/><category term="Suported"/><category term="Text Types"/><category term="Unicode Strings"/><category term="Upgrade"/><category term="mysql_affected_rows()"/><title type='text'>MySQL Tutorial</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-316532415128145912.post-3495738785352777182</id><published>2011-04-04T09:59:00.000-07:00</published><updated>2011-04-04T09:59:02.159-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mysql_affected_rows()"/><title type='text'>Get number of affected rows in previous MySQL operation</title><content type='html'>mysql_affected_rows (&lt;i&gt;PHP 4, PHP 5&lt;/i&gt;)&lt;br /&gt;
&lt;br /&gt;
Desc:&lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;type&quot;&gt;int &lt;b&gt;mysql_affected_rows&lt;/b&gt; ([ resource &lt;i&gt;$link_identifier&lt;/i&gt; ] )&lt;/span&gt;&lt;/blockquote&gt;&lt;span class=&quot;type&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;type&quot;&gt;Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query associated with &lt;i&gt;link_identifier&lt;/i&gt;. &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;type&quot;&gt;Example &lt;b&gt;mysql_affected_rows()&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;type&quot;&gt;&lt;/span&gt;&amp;lt;?php&lt;br /&gt;
$link = mysql_connect(&#39;localhost&#39;, &#39;mysql_user&#39;, &#39;mysql_password&#39;);&lt;br /&gt;
if (!$link) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; die(&#39;Could not connect: &#39; . mysql_error());&lt;br /&gt;
}&lt;br /&gt;
mysql_select_db(&#39;mydb&#39;);&lt;br /&gt;
&lt;br /&gt;
/* this should return the correct numbers of deleted records */&lt;br /&gt;
mysql_query(&#39;DELETE FROM mytable WHERE id &amp;lt; 10&#39;);&lt;br /&gt;
printf(&quot;Records deleted: %d\n&quot;, mysql_affected_rows());&lt;br /&gt;
&lt;br /&gt;
/* with a where clause that is never true, it should return 0 */&lt;br /&gt;
mysql_query(&#39;DELETE FROM mytable WHERE 0&#39;);&lt;br /&gt;
printf(&quot;Records deleted: %d\n&quot;, mysql_affected_rows());&lt;br /&gt;
?&amp;gt;&lt;/blockquote&gt;&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;mysql_affected_rows() does not count rows affected implicitly through the use of ON DELETE CASCADE and/or ON UPDATE CASCADE in foreign key constraints.&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/3495738785352777182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/04/get-number-of-affected-rows-in-previous.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/3495738785352777182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/3495738785352777182'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/04/get-number-of-affected-rows-in-previous.html' title='Get number of affected rows in previous MySQL operation'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-904140960365046493</id><published>2011-03-28T16:29:00.001-07:00</published><updated>2011-03-28T16:29:41.993-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><category scheme="http://www.blogger.com/atom/ns#" term="Other Types"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Data Types in SQL Server  -  Other Types</title><content type='html'>&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;80%&quot;&gt;Description&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;sql_variant&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Stores up to 8,000 bytes of data of various    data types, except text, ntext, and timestamp&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;uniqueidentifier&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Stores a globally unique identifier (GUID)&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;xml&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Stores XML formatted data. Maximum 2GB&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;cursor&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Stores a reference to a cursor used for    database operations&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;table&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Stores a result-set for later processing&lt;/td&gt;     &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/904140960365046493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-other-types.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/904140960365046493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/904140960365046493'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-other-types.html' title='Data Types in SQL Server  -  Other Types'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-316532415128145912.post-8219245242057674158</id><published>2011-03-28T16:28:00.000-07:00</published><updated>2011-03-28T16:28:28.569-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><category scheme="http://www.blogger.com/atom/ns#" term="Date Types"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Data Types in SQL Server - Date Types</title><content type='html'>&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;70%&quot;&gt;Description&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;Storage&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;datetime&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;From January 1, 1753 to December 31, 9999    with an accuracy of 3.33 milliseconds&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;8 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;datetime2&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;From January 1, 0001 to December 31, 9999    with an accuracy of 100 nanoseconds&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;6-8 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;smalldatetime&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;From January 1, 1900 to June 6, 2079 with an    accuracy of 1 minute&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;4 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;date&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Store a date only. From January 1, 0001 to    December 31, 9999&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;3 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;time&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Store a time only to an accuracy of 100    nanoseconds&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;3-5 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;datetimeoffset&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;The same as datetime2 with the addition of a    time zone offset&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;8-10 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;timestamp&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Stores a unique number that gets updated    every time a row gets created or modified. The timestamp value is based    upon an internal clock and does not correspond to real time. Each table    may have only one timestamp variable&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/8219245242057674158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-date-types.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8219245242057674158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8219245242057674158'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-date-types.html' title='Data Types in SQL Server - Date Types'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-5569214256110100044</id><published>2011-03-28T16:27:00.000-07:00</published><updated>2011-03-28T16:27:20.429-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><category scheme="http://www.blogger.com/atom/ns#" term="Number Types"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Data Types in SQL Server - Number Types</title><content type='html'>&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;70%&quot;&gt;Description&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;Storage&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;tinyint&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Allows whole numbers from 0 to 255&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;1 byte&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;smallint&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Allows whole numbers between -32,768 and    32,767&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;2 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;int&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Allows whole numbers between -2,147,483,648    and 2,147,483,647 &lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;4 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;bigint&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Allows whole numbers between    -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 &lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;8 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;decimal(p,s)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Fixed precision and scale numbers.       Allows numbers from -10^38 +1 to 10^38 –1.&lt;br /&gt;
The p parameter indicates the maximum total    number of digits that can be stored (both to the left and to the    right of the decimal point). p must be a value from 1 to 38. Default is 18.&lt;br /&gt;
The s parameter indicates the maximum number of digits stored to the right of the decimal point. s must be a value from 0 to    p. Default value is 0&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;5-17 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;numeric(p,s)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Fixed precision and scale numbers.       Allows numbers from -10^38 +1 to 10^38 –1.&lt;br /&gt;
The p parameter indicates the maximum total    number of digits that can be stored (both to the left and to the    right of the decimal point). p must be a value from 1 to 38. Default is    18.&lt;br /&gt;
The s parameter indicates the maximum number of digits    stored to the right of the decimal point. s must be a value from 0 to    p. Default value is 0&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;5-17 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;smallmoney&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Monetary data from -214,748.3648 to    214,748.3647 &lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;4 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;money&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Monetary data from -922,337,203,685,477.5808    to 922,337,203,685,477.5807&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;8 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;float(n)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Floating precision number data from -1.79E +    308 to 1.79E + 308.The n parameter indicates whether the field should    hold 4 or 8 bytes. float(24) holds a 4-byte field and float(53) holds    an 8-byte field. Default value of n is 53.&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;4 or 8 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;real&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Floating precision number data from -3.40E +    38 to 3.40E + 38&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;4 bytes&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/5569214256110100044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-number-types.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/5569214256110100044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/5569214256110100044'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-number-types.html' title='Data Types in SQL Server - Number Types'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-8495947366686473246</id><published>2011-03-28T16:25:00.001-07:00</published><updated>2011-03-28T16:25:54.649-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Binary"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Data Types in SQL Server - Binary</title><content type='html'>&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;70%&quot;&gt;Description&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;Storage&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;bit&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Allows 0, 1, or NULL&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;binary(n)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Fixed-length binary data. Maximum 8,000    bytes&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;varbinary(n)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Variable-length binary data. Maximum 8,000    bytes&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;varbinary(max)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Variable-length binary data. Maximum 2GB&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;image&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Variable-length binary data. Maximum 2GB&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/8495947366686473246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-binary.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8495947366686473246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8495947366686473246'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-binary.html' title='Data Types in SQL Server - Binary'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-1961268225607864245</id><published>2011-03-28T16:23:00.000-07:00</published><updated>2011-03-28T16:23:47.860-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Unicode Strings"/><title type='text'>Data Types in SQL Server - Unicode strings</title><content type='html'>&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;70%&quot;&gt;Description&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;Storage&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;nchar(n)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Fixed-length Unicode data. Maximum 4,000    characters&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;nvarchar(n)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Variable-length Unicode data. Maximum 4,000    characters&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;nvarchar(max)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Variable-length Unicode data. Maximum    536,870,912 characters&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;ntext&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Variable-length Unicode data. Maximum 2GB of    text data&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&lt;/td&gt;     &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/1961268225607864245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-unicode.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/1961268225607864245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/1961268225607864245'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-unicode.html' title='Data Types in SQL Server - Unicode strings'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-7268148661521399595</id><published>2011-03-28T16:22:00.000-07:00</published><updated>2011-03-28T16:22:28.619-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Character Strings"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>Data Types in SQL Server - Character strings</title><content type='html'>&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;70%&quot;&gt;Description&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;Storage&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;char(n)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Fixed-length character string. Maximum 8,000    characters&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;n&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;varchar(n)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Variable-length character string. Maximum    8,000 characters&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;varchar(max)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Variable-length character string. Maximum    1,073,741,824 characters&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;text&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Variable-length character string. Maximum    2GB of text data&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&amp;nbsp;&lt;/td&gt;     &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/7268148661521399595/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-character.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/7268148661521399595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/7268148661521399595'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-sql-server-character.html' title='Data Types in SQL Server - Character strings'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-2842485279487426003</id><published>2011-03-28T16:20:00.000-07:00</published><updated>2011-03-28T16:20:23.803-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><category scheme="http://www.blogger.com/atom/ns#" term="Date Types"/><title type='text'>Data Types in MySQL -  Date Types</title><content type='html'>&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;80%&quot;&gt;Description&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;DATE()&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;A date. Format: YYYY-MM-DD&lt;b&gt;Note:&lt;/b&gt; The supported range    is from &#39;1000-01-01&#39; to &#39;9999-12-31&#39;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;DATETIME()&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;*A date and time combination. Format: YYYY-MM-DD HH:MM:SS&lt;b&gt;Note:&lt;/b&gt; The supported range    is from &#39;1000-01-01 00:00:00&#39; to &#39;9999-12-31 23:59:59&#39;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;TIMESTAMP()&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;*A timestamp. TIMESTAMP values are stored as    the number of seconds since the Unix epoch (&#39;1970-01-01 00:00:00&#39; UTC).    Format: YYYY-MM-DD HH:MM:SS&lt;b&gt;Note:&lt;/b&gt; The supported range is from &#39;1970-01-01 00:00:01&#39; UTC to    &#39;2038-01-09 03:14:07&#39; UTC&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;TIME()&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;A time. Format: HH:MM:SS&lt;b&gt;Note:&lt;/b&gt; The supported range is from    &#39;-838:59:59&#39; to &#39;838:59:59&#39;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;YEAR()&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;A year in two-digit or four-digit format.   &lt;b&gt;Note:&lt;/b&gt; Values allowed in four-digit format: 1901 to 2155. Values    allowed in two-digit format: 70 to 69, representing years from 1970 to    2069&lt;/td&gt;     &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/2842485279487426003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-mysql-date-types.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/2842485279487426003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/2842485279487426003'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-mysql-date-types.html' title='Data Types in MySQL -  Date Types'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-2761599689951687843</id><published>2011-03-28T16:18:00.000-07:00</published><updated>2011-03-28T16:18:59.681-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><category scheme="http://www.blogger.com/atom/ns#" term="Number Types"/><title type='text'>Data Types in MySQL -  Number types</title><content type='html'>&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;80%&quot;&gt;Description&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;TINYINT(size)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;-128 to 127 normal. 0 to 255 UNSIGNED*. The    maximum number of digits may be specified in parenthesis&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;SMALLINT(size)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;-32768 to 32767 normal. 0 to 65535 UNSIGNED*.    The maximum number of digits may be specified in parenthesis&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;MEDIUMINT(size)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;-8388608 to 8388607 normal. 0 to 16777215    UNSIGNED*. The maximum number of digits may be specified in parenthesis&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;INT(size)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;-2147483648 to 2147483647 normal. 0 to    4294967295 UNSIGNED*. The maximum number of digits may be specified in    parenthesis&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;BIGINT(size)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;-9223372036854775808 to 9223372036854775807    normal. 0 to 18446744073709551615 UNSIGNED*. The maximum number of    digits may be specified in parenthesis&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;FLOAT(size,d)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;A small number with a floating decimal point.    The maximum number of digits may be specified in the size parameter. The    maximum number of digits to the right of the decimal point is specified in the    d parameter&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;DOUBLE(size,d)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;A large number with a floating decimal point.    The maximum number of digits may be specified in the size parameter. The    maximum number of digits to the right of the decimal point is specified in the    d parameter&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;DECIMAL(size,d)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;A DOUBLE stored as a string , allowing for a    fixed decimal point. The maximum number of digits may be specified in    the size parameter. The maximum number of digits to the right of the    decimal point is specified in the d parameter&lt;/td&gt;     &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/2761599689951687843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-mysql-number-types.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/2761599689951687843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/2761599689951687843'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-mysql-number-types.html' title='Data Types in MySQL -  Number types'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-4868359530001077225</id><published>2011-03-28T16:15:00.000-07:00</published><updated>2011-03-28T16:16:36.478-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><category scheme="http://www.blogger.com/atom/ns#" term="Text Types"/><title type='text'>Data Types in MySQL -  Text Types</title><content type='html'>&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;80%&quot;&gt;Description&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;CHAR(size)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Holds a fixed length string (can contain    letters, numbers, and special characters). The fixed size is specified    in parenthesis. Can store    up to 255 characters&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;VARCHAR(size)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Holds a variable length string (can contain    letters, numbers, and special characters). The maximum size is specified    in parenthesis. Can store    up to 255 characters. &lt;b&gt;Note:&lt;/b&gt; If you put a greater value than 255    it will be converted to a TEXT type&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;TINYTEXT&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Holds a string with a maximum    length of 255 characters&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;TEXT&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Holds a string with a maximum length of    65,535 characters&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;BLOB&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;For BLOBs (Binary Large OBjects). Holds up to 65,535 bytes of data&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;MEDIUMTEXT&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Holds a string with a maximum length of    16,777,215 characters&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;MEDIUMBLOB&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;For BLOBs (Binary Large OBjects). Holds up to 16,777,215 bytes of data&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;LONGTEXT&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Holds a string with a maximum length of    4,294,967,295 characters&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;LONGBLOB&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;For BLOBs (Binary Large OBjects). Holds up to 4,294,967,295 bytes of data&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;ENUM(x,y,z,etc.)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Let you enter a list of possible    values. You can list up to 65535 values in an ENUM list. If a value is    inserted that is not in the list, a blank value will be inserted.&lt;b&gt;   Note:&lt;/b&gt; The values are sorted in the    order you enter them.&lt;br /&gt;
You enter the possible values in this format:   ENUM(&#39;X&#39;,&#39;Y&#39;,&#39;Z&#39;)&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;SET&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Similar to ENUM except that SET may contain    up to 64 list items and can store more than one choice&lt;/td&gt;     &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/4868359530001077225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-mysql-text-types-part1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/4868359530001077225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/4868359530001077225'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-mysql-text-types-part1.html' title='Data Types in MySQL -  Text Types'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-5924655243498349571</id><published>2011-03-28T16:12:00.000-07:00</published><updated>2011-03-28T19:53:48.391-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Types"/><title type='text'>Data Types in Microsoft Access</title><content type='html'>&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;reference&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Data type&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;70%&quot;&gt;Description&lt;/th&gt;       &lt;th align=&quot;left&quot; valign=&quot;top&quot; width=&quot;10%&quot;&gt;Storage&lt;/th&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Text&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Use for text or combinations of text and    numbers. 255 characters maximum&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Memo&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Memo is used for larger amounts of text.    Stores up to 65,536 characters. &lt;b&gt;Note:&lt;/b&gt; You cannot sort a memo field.    However, they are searchable&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Byte&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Allows whole numbers from 0 to 255&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;1 byte&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Integer&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Allows whole numbers between -32,768 and    32,767&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;2 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Long&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Allows whole numbers between -2,147,483,648    and 2,147,483,647&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;4 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Single&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Single precision floating-point. Will handle    most decimals &lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;4 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Double&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Double precision floating-point. Will handle    most decimals&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;8 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Currency&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Use for currency.    Holds up to 15 digits of whole dollars, plus 4 decimal places. &lt;b&gt;Tip:&lt;/b&gt; You can choose which country&#39;s currency to use&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;8 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;AutoNumber&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;AutoNumber fields automatically give each    record its own number, usually starting at 1&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;4 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Date/Time&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Use for dates and times&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;8 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Yes/No&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;A logical field can be displayed as Yes/No,    True/False, or On/Off. In code, use the constants True and False    (equivalent to -1 and 0). &lt;b&gt;Note:&lt;/b&gt; Null values are not allowed in    Yes/No fields&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;1 bit&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Ole Object&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Can store pictures, audio, video, or other    BLOBs (Binary Large OBjects)&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;up to 1GB&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Hyperlink&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Contain links to other    files, including web pages&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&lt;/td&gt;     &lt;/tr&gt;
&lt;tr&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Lookup Wizard&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;Let you type a list of options,    which can then be chosen from a drop-down list&lt;/td&gt;       &lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;4 bytes&lt;/td&gt;     &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;iframe align=&quot;left&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://rcm.amazon.com/e/cm?t=my0515-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=0672327120&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr&quot; style=&quot;height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/5924655243498349571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-microsoft-access.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/5924655243498349571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/5924655243498349571'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/data-types-in-microsoft-access.html' title='Data Types in Microsoft Access'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-1243901224094597850</id><published>2011-03-27T13:43:00.000-07:00</published><updated>2011-03-27T13:43:07.881-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Pattern"/><title type='text'>Pattern Matching</title><content type='html'>MySQL provides standard SQL pattern matching as well as a form           of pattern matching based on extended regular expressions           similar to those used by Unix utilities such as           &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;vi&lt;/strong&gt;&lt;/span&gt;, &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;grep&lt;/strong&gt;&lt;/span&gt;, and           &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;sed&lt;/strong&gt;&lt;/span&gt;.         &lt;br /&gt;
SQL pattern matching allows you to use           ‘&lt;code class=&quot;literal&quot;&gt;_&lt;/code&gt;’ to match any single           character and ‘&lt;code class=&quot;literal&quot;&gt;%&lt;/code&gt;’ to match an           arbitrary number of characters (including zero characters). In           MySQL, SQL patterns are case-insensitive by default. Some           examples are shown here. Note that you do not use           &lt;code class=&quot;literal&quot;&gt;=&lt;/code&gt; or &lt;code class=&quot;literal&quot;&gt;&amp;lt;&amp;gt;&lt;/code&gt; when you           use SQL patterns; use the &lt;code class=&quot;literal&quot;&gt;LIKE&lt;/code&gt; or           &lt;code class=&quot;literal&quot;&gt;NOT LIKE&lt;/code&gt; comparison operators instead.         &lt;br /&gt;
To find names beginning with           ‘&lt;code class=&quot;literal&quot;&gt;b&lt;/code&gt;’:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name LIKE &#39;b%&#39;;&lt;/code&gt;&lt;/strong&gt;
+--------+--------+---------+------+------------+------------+
| name   | owner  | species | sex  | birth      | death      |
+--------+--------+---------+------+------------+------------+
| Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
| Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
+--------+--------+---------+------+------------+------------+
&lt;/pre&gt;To find names ending with ‘&lt;code class=&quot;literal&quot;&gt;fy&lt;/code&gt;’:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name LIKE &#39;%fy&#39;;&lt;/code&gt;&lt;/strong&gt;
+--------+--------+---------+------+------------+-------+
| name   | owner  | species | sex  | birth      | death |
+--------+--------+---------+------+------------+-------+
| Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
| Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
+--------+--------+---------+------+------------+-------+
&lt;/pre&gt;To find names containing a ‘&lt;code class=&quot;literal&quot;&gt;w&lt;/code&gt;’:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name LIKE &#39;%w%&#39;;&lt;/code&gt;&lt;/strong&gt;
+----------+-------+---------+------+------------+------------+
| name     | owner | species | sex  | birth      | death      |
+----------+-------+---------+------+------------+------------+
| Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
| Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
| Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
+----------+-------+---------+------+------------+------------+
&lt;/pre&gt;To find names containing exactly five characters, use five           instances of the ‘&lt;code class=&quot;literal&quot;&gt;_&lt;/code&gt;’ pattern           character:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name LIKE &#39;_____&#39;;&lt;/code&gt;&lt;/strong&gt;
+-------+--------+---------+------+------------+-------+
| name  | owner  | species | sex  | birth      | death |
+-------+--------+---------+------+------------+-------+
| Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
| Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
+-------+--------+---------+------+------------+-------+
&lt;/pre&gt;The other type of pattern matching provided by MySQL uses           extended regular expressions. When you test for a match for           this type of pattern, use the &lt;code class=&quot;literal&quot;&gt;REGEXP&lt;/code&gt; and           &lt;code class=&quot;literal&quot;&gt;NOT REGEXP&lt;/code&gt; operators (or           &lt;code class=&quot;literal&quot;&gt;RLIKE&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;NOT RLIKE&lt;/code&gt;,           which are synonyms).         &lt;br /&gt;
Some characteristics of extended regular expressions are:         &lt;br /&gt;
&lt;div class=&quot;itemizedlist&quot;&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li&gt;               ‘&lt;code class=&quot;literal&quot;&gt;.&lt;/code&gt;’ matches any single               character.             &lt;/li&gt;
&lt;li&gt;               A character class ‘&lt;code class=&quot;literal&quot;&gt;[...]&lt;/code&gt;’               matches any character within the brackets. For example,               ‘&lt;code class=&quot;literal&quot;&gt;[abc]&lt;/code&gt;’ matches               ‘&lt;code class=&quot;literal&quot;&gt;a&lt;/code&gt;’,               ‘&lt;code class=&quot;literal&quot;&gt;b&lt;/code&gt;’, or               ‘&lt;code class=&quot;literal&quot;&gt;c&lt;/code&gt;’. To name a range of               characters, use a dash.               ‘&lt;code class=&quot;literal&quot;&gt;[a-z]&lt;/code&gt;’ matches any letter,               whereas ‘&lt;code class=&quot;literal&quot;&gt;[0-9]&lt;/code&gt;’ matches any               digit.             &lt;/li&gt;
&lt;li&gt;               ‘&lt;code class=&quot;literal&quot;&gt;*&lt;/code&gt;’ matches zero or more               instances of the thing preceding it. For example,               ‘&lt;code class=&quot;literal&quot;&gt;x*&lt;/code&gt;’ matches any number of               ‘&lt;code class=&quot;literal&quot;&gt;x&lt;/code&gt;’ characters,               ‘&lt;code class=&quot;literal&quot;&gt;[0-9]*&lt;/code&gt;’ matches any number               of digits, and ‘&lt;code class=&quot;literal&quot;&gt;.*&lt;/code&gt;’ matches               any number of anything.             &lt;/li&gt;
&lt;li&gt;               A &lt;code class=&quot;literal&quot;&gt;REGEXP&lt;/code&gt; pattern match succeeds if the               pattern matches anywhere in the value being tested. (This               differs from a &lt;code class=&quot;literal&quot;&gt;LIKE&lt;/code&gt; pattern match,               which succeeds only if the pattern matches the entire               value.)             &lt;/li&gt;
&lt;li&gt;               To anchor a pattern so that it must match the beginning or               end of the value being tested, use               ‘&lt;code class=&quot;literal&quot;&gt;^&lt;/code&gt;’ at the beginning or               ‘&lt;code class=&quot;literal&quot;&gt;$&lt;/code&gt;’ at the end of the               pattern.             &lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;To demonstrate how extended regular expressions work, the           &lt;code class=&quot;literal&quot;&gt;LIKE&lt;/code&gt; queries shown previously are rewritten           here to use &lt;code class=&quot;literal&quot;&gt;REGEXP&lt;/code&gt;.         &lt;br /&gt;
To find names beginning with           ‘&lt;code class=&quot;literal&quot;&gt;b&lt;/code&gt;’, use           ‘&lt;code class=&quot;literal&quot;&gt;^&lt;/code&gt;’ to match the beginning of           the name:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name REGEXP &#39;^b&#39;;&lt;/code&gt;&lt;/strong&gt;
+--------+--------+---------+------+------------+------------+
| name   | owner  | species | sex  | birth      | death      |
+--------+--------+---------+------+------------+------------+
| Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
| Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
+--------+--------+---------+------+------------+------------+
&lt;/pre&gt;Prior to MySQL 3.23.4, &lt;code class=&quot;literal&quot;&gt;REGEXP&lt;/code&gt; is case           sensitive, and the previous query will return no rows. In this           case, to match either lowercase or uppercase           ‘&lt;code class=&quot;literal&quot;&gt;b&lt;/code&gt;’, use this query instead:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name REGEXP &#39;^[bB]&#39;;&lt;/code&gt;&lt;/strong&gt;
&lt;/pre&gt;From MySQL 3.23.4 on, if you really want to force a           &lt;code class=&quot;literal&quot;&gt;REGEXP&lt;/code&gt; comparison to be case sensitive, use           the &lt;code class=&quot;literal&quot;&gt;BINARY&lt;/code&gt; keyword to make one of the           strings a binary string. This query matches only lowercase           ‘&lt;code class=&quot;literal&quot;&gt;b&lt;/code&gt;’ at the beginning of a name:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name REGEXP BINARY &#39;^b&#39;;&lt;/code&gt;&lt;/strong&gt;
&lt;/pre&gt;To find names ending with ‘&lt;code class=&quot;literal&quot;&gt;fy&lt;/code&gt;’,           use ‘&lt;code class=&quot;literal&quot;&gt;$&lt;/code&gt;’ to match the end of the           name:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name REGEXP &#39;fy$&#39;;&lt;/code&gt;&lt;/strong&gt;
+--------+--------+---------+------+------------+-------+
| name   | owner  | species | sex  | birth      | death |
+--------+--------+---------+------+------------+-------+
| Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
| Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
+--------+--------+---------+------+------------+-------+
&lt;/pre&gt;To find names containing a ‘&lt;code class=&quot;literal&quot;&gt;w&lt;/code&gt;’,           use this query:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name REGEXP &#39;w&#39;;&lt;/code&gt;&lt;/strong&gt;
+----------+-------+---------+------+------------+------------+
| name     | owner | species | sex  | birth      | death      |
+----------+-------+---------+------+------------+------------+
| Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
| Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
| Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
+----------+-------+---------+------+------------+------------+
&lt;/pre&gt;Because a regular expression pattern matches if it occurs           anywhere in the value, it is not necessary in the previous           query to put a wildcard on either side of the pattern to get           it to match the entire value like it would be if you used an           SQL pattern.         &lt;br /&gt;
To find names containing exactly five characters, use           ‘&lt;code class=&quot;literal&quot;&gt;^&lt;/code&gt;’ and           ‘&lt;code class=&quot;literal&quot;&gt;$&lt;/code&gt;’ to match the beginning and           end of the name, and five instances of           ‘&lt;code class=&quot;literal&quot;&gt;.&lt;/code&gt;’ in between:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name REGEXP &#39;^.....$&#39;;&lt;/code&gt;&lt;/strong&gt;
+-------+--------+---------+------+------------+-------+
| name  | owner  | species | sex  | birth      | death |
+-------+--------+---------+------+------------+-------+
| Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
| Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
+-------+--------+---------+------+------------+-------+
&lt;/pre&gt;You could also write the previous query using the           &lt;code class=&quot;literal&quot;&gt;{&lt;em class=&quot;replaceable&quot;&gt;&lt;code&gt;n&lt;/code&gt;&lt;/em&gt;}&lt;/code&gt;           (“&lt;span class=&quot;quote&quot;&gt;repeat-&lt;em class=&quot;replaceable&quot;&gt;&lt;code&gt;n&lt;/code&gt;&lt;/em&gt;-times&lt;/span&gt;”)           operator:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name REGEXP &#39;^.{5}$&#39;;&lt;/code&gt;&lt;/strong&gt;
+-------+--------+---------+------+------------+-------+
| name  | owner  | species | sex  | birth      | death |
+-------+--------+---------+------+------------+-------+
| Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
| Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
+-------+--------+---------+------+------------+-------+
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/1243901224094597850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/pattern-matching.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/1243901224094597850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/1243901224094597850'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/pattern-matching.html' title='Pattern Matching'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-316532415128145912.post-4507839184639097904</id><published>2011-03-27T13:42:00.000-07:00</published><updated>2011-03-27T13:42:04.894-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NULL"/><title type='text'>Working with NULL Values</title><content type='html'>The &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; value can be surprising until you           get used to it. Conceptually, &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; means           “&lt;span class=&quot;quote&quot;&gt;a missing unknown value&lt;/span&gt;” and it is treated           somewhat differently from other values. To test for           &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt;, you cannot use the arithmetic           comparison operators such as &lt;code class=&quot;literal&quot;&gt;=&lt;/code&gt;,           &lt;code class=&quot;literal&quot;&gt;&amp;lt;&lt;/code&gt;, or &lt;code class=&quot;literal&quot;&gt;&amp;lt;&amp;gt;&lt;/code&gt;. To           demonstrate this for yourself, try the following query:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT 1 = NULL, 1 &amp;lt;&amp;gt; NULL, 1 &amp;lt; NULL, 1 &amp;gt; NULL;&lt;/code&gt;&lt;/strong&gt;
+----------+-----------+----------+----------+
| 1 = NULL | 1 &amp;lt;&amp;gt; NULL | 1 &amp;lt; NULL | 1 &amp;gt; NULL |
+----------+-----------+----------+----------+
|     NULL |      NULL |     NULL |     NULL |
+----------+-----------+----------+----------+
&lt;/pre&gt;Clearly you get no meaningful results from these comparisons.           Use the &lt;code class=&quot;literal&quot;&gt;IS NULL&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;IS NOT           NULL&lt;/code&gt; operators instead:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT 1 IS NULL, 1 IS NOT NULL;&lt;/code&gt;&lt;/strong&gt;
+-----------+---------------+
| 1 IS NULL | 1 IS NOT NULL |
+-----------+---------------+
|         0 |             1 |
+-----------+---------------+
&lt;/pre&gt;Note that in MySQL, &lt;code class=&quot;literal&quot;&gt;0&lt;/code&gt; or           &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; means false and anything else means           true. The default truth value from a boolean operation is           &lt;code class=&quot;literal&quot;&gt;1&lt;/code&gt;.         &lt;br /&gt;
This special treatment of &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; is why, in           the previous section, it was necessary to determine which           animals are no longer alive using &lt;code class=&quot;literal&quot;&gt;death IS NOT           NULL&lt;/code&gt; instead of &lt;code class=&quot;literal&quot;&gt;death &amp;lt;&amp;gt;           NULL&lt;/code&gt;.         &lt;br /&gt;
Two &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; values are regarded as equal in a           &lt;code class=&quot;literal&quot;&gt;GROUP BY&lt;/code&gt;.         &lt;br /&gt;
When doing an &lt;code class=&quot;literal&quot;&gt;ORDER BY&lt;/code&gt;,           &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; values are presented first if you do           &lt;code class=&quot;literal&quot;&gt;ORDER BY ... ASC&lt;/code&gt; and last if you do           &lt;code class=&quot;literal&quot;&gt;ORDER BY ... DESC&lt;/code&gt;.         &lt;br /&gt;
Note that MySQL 4.0.2 to 4.0.10 incorrectly always sorts           &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; values first regardless of the sort           direction.         &lt;br /&gt;
A common error when working with &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; is to           assume that it is not possible to insert a zero or an empty           string into a column defined as &lt;code class=&quot;literal&quot;&gt;NOT NULL&lt;/code&gt;,           but this is not the case. These are in fact values, whereas           &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; means “&lt;span class=&quot;quote&quot;&gt;not having a           value.&lt;/span&gt;” You can test this easily enough by using           &lt;code class=&quot;literal&quot;&gt;IS &lt;/code&gt;[&lt;code class=&quot;literal&quot;&gt;NOT&lt;/code&gt;]&lt;code class=&quot;literal&quot;&gt;           NULL&lt;/code&gt; as shown:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT 0 IS NULL, 0 IS NOT NULL, &#39;&#39; IS NULL, &#39;&#39; IS NOT NULL;&lt;/code&gt;&lt;/strong&gt;
+-----------+---------------+------------+----------------+
| 0 IS NULL | 0 IS NOT NULL | &#39;&#39; IS NULL | &#39;&#39; IS NOT NULL |
+-----------+---------------+------------+----------------+
|         0 |             1 |          0 |              1 |
+-----------+---------------+------------+----------------+
&lt;/pre&gt;Thus it is entirely possible to insert a zero or empty string           into a &lt;code class=&quot;literal&quot;&gt;NOT NULL&lt;/code&gt; column, as these are in           fact &lt;code class=&quot;literal&quot;&gt;NOT NULL&lt;/code&gt;.</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/4507839184639097904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/working-with-null-values.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/4507839184639097904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/4507839184639097904'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/working-with-null-values.html' title='Working with NULL Values'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-7028813347619277844</id><published>2011-03-27T13:40:00.000-07:00</published><updated>2011-03-27T13:40:04.448-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Calculate"/><category scheme="http://www.blogger.com/atom/ns#" term="Date"/><title type='text'>Date Calculations</title><content type='html'>MySQL provides several functions that you can use to perform           calculations on dates, for example, to calculate ages or           extract parts of dates.         &lt;br /&gt;
To determine how many years old each of your pets is, compute           the difference in the year part of the current date and the           birth date, then subtract one if the current date occurs           earlier in the calendar year than the birth date. The           following query shows, for each pet, the birth date, the           current date, and the age in years.         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth, CURDATE(),&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;(YEAR(CURDATE())-YEAR(birth))&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;- (RIGHT(CURDATE(),5)&amp;lt;RIGHT(birth,5))&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;AS age&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;FROM pet;&lt;/code&gt;&lt;/strong&gt;
+----------+------------+------------+------+
| name     | birth      | CURDATE()  | age  |
+----------+------------+------------+------+
| Fluffy   | 1993-02-04 | 2003-08-19 |   10 |
| Claws    | 1994-03-17 | 2003-08-19 |    9 |
| Buffy    | 1989-05-13 | 2003-08-19 |   14 |
| Fang     | 1990-08-27 | 2003-08-19 |   12 |
| Bowser   | 1989-08-31 | 2003-08-19 |   13 |
| Chirpy   | 1998-09-11 | 2003-08-19 |    4 |
| Whistler | 1997-12-09 | 2003-08-19 |    5 |
| Slim     | 1996-04-29 | 2003-08-19 |    7 |
| Puffball | 1999-03-30 | 2003-08-19 |    4 |
+----------+------------+------------+------+
&lt;/pre&gt;Here, &lt;code class=&quot;literal&quot;&gt;YEAR()&lt;/code&gt; pulls out the year part of a           date and &lt;code class=&quot;literal&quot;&gt;RIGHT()&lt;/code&gt; pulls off the rightmost           five characters that represent the &lt;code class=&quot;literal&quot;&gt;MM-DD&lt;/code&gt;           (calendar year) part of the date. The part of the expression           that compares the &lt;code class=&quot;literal&quot;&gt;MM-DD&lt;/code&gt; values evaluates to           1 or 0, which adjusts the year difference down a year if           &lt;code class=&quot;literal&quot;&gt;CURDATE()&lt;/code&gt; occurs earlier in the year than           &lt;code class=&quot;literal&quot;&gt;birth&lt;/code&gt;. The full expression is somewhat           ungainly, so an &lt;span class=&quot;emphasis&quot;&gt;&lt;em&gt;alias&lt;/em&gt;&lt;/span&gt;           (&lt;code class=&quot;literal&quot;&gt;age&lt;/code&gt;) is used to make the output column           label more meaningful.         &lt;br /&gt;
The query works, but the result could be scanned more easily           if the rows were presented in some order. This can be done by           adding an &lt;code class=&quot;literal&quot;&gt;ORDER BY name&lt;/code&gt; clause to sort the           output by name:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth, CURDATE(),&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;(YEAR(CURDATE())-YEAR(birth))&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;- (RIGHT(CURDATE(),5)&amp;lt;RIGHT(birth,5))&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;AS age&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;FROM pet ORDER BY name;&lt;/code&gt;&lt;/strong&gt;
+----------+------------+------------+------+
| name     | birth      | CURDATE()  | age  |
+----------+------------+------------+------+
| Bowser   | 1989-08-31 | 2003-08-19 |   13 |
| Buffy    | 1989-05-13 | 2003-08-19 |   14 |
| Chirpy   | 1998-09-11 | 2003-08-19 |    4 |
| Claws    | 1994-03-17 | 2003-08-19 |    9 |
| Fang     | 1990-08-27 | 2003-08-19 |   12 |
| Fluffy   | 1993-02-04 | 2003-08-19 |   10 |
| Puffball | 1999-03-30 | 2003-08-19 |    4 |
| Slim     | 1996-04-29 | 2003-08-19 |    7 |
| Whistler | 1997-12-09 | 2003-08-19 |    5 |
+----------+------------+------------+------+
&lt;/pre&gt;To sort the output by &lt;code class=&quot;literal&quot;&gt;age&lt;/code&gt; rather than           &lt;code class=&quot;literal&quot;&gt;name&lt;/code&gt;, just use a different &lt;code class=&quot;literal&quot;&gt;ORDER           BY&lt;/code&gt; clause:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth, CURDATE(),&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;(YEAR(CURDATE())-YEAR(birth))&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;- (RIGHT(CURDATE(),5)&amp;lt;RIGHT(birth,5))&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;AS age&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;FROM pet ORDER BY age;&lt;/code&gt;&lt;/strong&gt;
+----------+------------+------------+------+
| name     | birth      | CURDATE()  | age  |
+----------+------------+------------+------+
| Chirpy   | 1998-09-11 | 2003-08-19 |    4 |
| Puffball | 1999-03-30 | 2003-08-19 |    4 |
| Whistler | 1997-12-09 | 2003-08-19 |    5 |
| Slim     | 1996-04-29 | 2003-08-19 |    7 |
| Claws    | 1994-03-17 | 2003-08-19 |    9 |
| Fluffy   | 1993-02-04 | 2003-08-19 |   10 |
| Fang     | 1990-08-27 | 2003-08-19 |   12 |
| Bowser   | 1989-08-31 | 2003-08-19 |   13 |
| Buffy    | 1989-05-13 | 2003-08-19 |   14 |
+----------+------------+------------+------+
&lt;/pre&gt;A similar query can be used to determine age at death for           animals that have died. You determine which animals these are           by checking whether the &lt;code class=&quot;literal&quot;&gt;death&lt;/code&gt; value is           &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt;. Then, for those with           non-&lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; values, compute the difference           between the &lt;code class=&quot;literal&quot;&gt;death&lt;/code&gt; and           &lt;code class=&quot;literal&quot;&gt;birth&lt;/code&gt; values:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth, death,&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;(YEAR(death)-YEAR(birth)) - (RIGHT(death,5)&amp;lt;RIGHT(birth,5))&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;AS age&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;FROM pet WHERE death IS NOT NULL ORDER BY age;&lt;/code&gt;&lt;/strong&gt;
+--------+------------+------------+------+
| name   | birth      | death      | age  |
+--------+------------+------------+------+
| Bowser | 1989-08-31 | 1995-07-29 |    5 |
+--------+------------+------------+------+
&lt;/pre&gt;The query uses &lt;code class=&quot;literal&quot;&gt;death IS NOT NULL&lt;/code&gt; rather           than &lt;code class=&quot;literal&quot;&gt;death &amp;lt;&amp;gt; NULL&lt;/code&gt; because           &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; is a special value that cannot be           compared using the usual comparison operators.&lt;br /&gt;
What if you want to know which animals have birthdays next           month? For this type of calculation, year and day are           irrelevant; you simply want to extract the month part of the           &lt;code class=&quot;literal&quot;&gt;birth&lt;/code&gt; column. MySQL provides several           functions for extracting parts of dates, such as           &lt;code class=&quot;literal&quot;&gt;YEAR()&lt;/code&gt;, &lt;code class=&quot;literal&quot;&gt;MONTH()&lt;/code&gt;, and           &lt;code class=&quot;literal&quot;&gt;DAYOFMONTH()&lt;/code&gt;. &lt;code class=&quot;literal&quot;&gt;MONTH()&lt;/code&gt; is           the appropriate function here. To see how it works, run a           simple query that displays the value of both           &lt;code class=&quot;literal&quot;&gt;birth&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;MONTH(birth)&lt;/code&gt;:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth, MONTH(birth) FROM pet;&lt;/code&gt;&lt;/strong&gt;
+----------+------------+--------------+
| name     | birth      | MONTH(birth) |
+----------+------------+--------------+
| Fluffy   | 1993-02-04 |            2 |
| Claws    | 1994-03-17 |            3 |
| Buffy    | 1989-05-13 |            5 |
| Fang     | 1990-08-27 |            8 |
| Bowser   | 1989-08-31 |            8 |
| Chirpy   | 1998-09-11 |            9 |
| Whistler | 1997-12-09 |           12 |
| Slim     | 1996-04-29 |            4 |
| Puffball | 1999-03-30 |            3 |
+----------+------------+--------------+
&lt;/pre&gt;Finding animals with birthdays in the upcoming month is also           simple. Suppose that the current month is April. Then the           month value is &lt;code class=&quot;literal&quot;&gt;4&lt;/code&gt; and you can look for           animals born in May (month &lt;code class=&quot;literal&quot;&gt;5&lt;/code&gt;) like this:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth FROM pet WHERE MONTH(birth) = 5;&lt;/code&gt;&lt;/strong&gt;
+-------+------------+
| name  | birth      |
+-------+------------+
| Buffy | 1989-05-13 |
+-------+------------+
&lt;/pre&gt;There is a small complication if the current month is           December. You cannot merely add one to the month number           (&lt;code class=&quot;literal&quot;&gt;12&lt;/code&gt;) and look for animals born in month           &lt;code class=&quot;literal&quot;&gt;13&lt;/code&gt;, because there is no such month.           Instead, you look for animals born in January (month           &lt;code class=&quot;literal&quot;&gt;1&lt;/code&gt;).         &lt;br /&gt;
You can write the query so that it works no matter what the           current month is, so that you do not have to use the number           for a particular month. &lt;code class=&quot;literal&quot;&gt;DATE_ADD()&lt;/code&gt; allows           you to add a time interval to a given date. If you add a month           to the value of &lt;code class=&quot;literal&quot;&gt;CURDATE()&lt;/code&gt;, then extract the           month part with &lt;code class=&quot;literal&quot;&gt;MONTH()&lt;/code&gt;, the result           produces the month in which to look for birthdays:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth FROM pet&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;WHERE MONTH(birth) = MONTH(DATE_ADD(CURDATE(),INTERVAL 1 MONTH));&lt;/code&gt;&lt;/strong&gt;
&lt;/pre&gt;A different way to accomplish the same task is to add           &lt;code class=&quot;literal&quot;&gt;1&lt;/code&gt; to get the next month after the current           one after using the modulo function (&lt;code class=&quot;literal&quot;&gt;MOD&lt;/code&gt;)           to wrap the month value to &lt;code class=&quot;literal&quot;&gt;0&lt;/code&gt; if it is           currently &lt;code class=&quot;literal&quot;&gt;12&lt;/code&gt;:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth FROM pet&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;WHERE MONTH(birth) = MOD(MONTH(CURDATE()), 12) + 1;&lt;/code&gt;&lt;/strong&gt;
&lt;/pre&gt;Note that &lt;code class=&quot;literal&quot;&gt;MONTH&lt;/code&gt; returns a number between           &lt;code class=&quot;literal&quot;&gt;1&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;12&lt;/code&gt;. And           &lt;code class=&quot;literal&quot;&gt;MOD(something,12)&lt;/code&gt; returns a number between           &lt;code class=&quot;literal&quot;&gt;0&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;11&lt;/code&gt;. So the           addition has to be after the &lt;code class=&quot;literal&quot;&gt;MOD()&lt;/code&gt;,           otherwise we would go from November (&lt;code class=&quot;literal&quot;&gt;11&lt;/code&gt;) to           January (&lt;code class=&quot;literal&quot;&gt;1&lt;/code&gt;).</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/7028813347619277844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/date-calculations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/7028813347619277844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/7028813347619277844'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/date-calculations.html' title='Date Calculations'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-6660646566570483604</id><published>2011-03-27T13:38:00.000-07:00</published><updated>2011-03-27T13:38:11.203-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Rows"/><category scheme="http://www.blogger.com/atom/ns#" term="Sort"/><title type='text'>Sorting Rows</title><content type='html'>You may have noticed in the preceding examples that the result           rows are displayed in no particular order. It&#39;s often easier           to examine query output when the rows are sorted in some           meaningful way. To sort a result, use an &lt;code class=&quot;literal&quot;&gt;ORDER           BY&lt;/code&gt; clause.         &lt;br /&gt;
Here are animal birthdays, sorted by date:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth FROM pet ORDER BY birth;&lt;/code&gt;&lt;/strong&gt;
+----------+------------+
| name     | birth      |
+----------+------------+
| Buffy    | 1989-05-13 |
| Bowser   | 1989-08-31 |
| Fang     | 1990-08-27 |
| Fluffy   | 1993-02-04 |
| Claws    | 1994-03-17 |
| Slim     | 1996-04-29 |
| Whistler | 1997-12-09 |
| Chirpy   | 1998-09-11 |
| Puffball | 1999-03-30 |
+----------+------------+
&lt;/pre&gt;On character type columns, sorting — like all other           comparison operations — is normally performed in a           case-insensitive fashion. This means that the order is           undefined for columns that are identical except for their           case. You can force a case-sensitive sort for a column by           using &lt;code class=&quot;literal&quot;&gt;BINARY&lt;/code&gt; like so: &lt;code class=&quot;literal&quot;&gt;ORDER BY           BINARY &lt;em class=&quot;replaceable&quot;&gt;&lt;code&gt;col_name&lt;/code&gt;&lt;/em&gt;&lt;/code&gt;.         &lt;br /&gt;
The default sort order is ascending, with smallest values           first. To sort in reverse (descending) order, add the           &lt;code class=&quot;literal&quot;&gt;DESC&lt;/code&gt; keyword to the name of the column you           are sorting by:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth FROM pet ORDER BY birth DESC;&lt;/code&gt;&lt;/strong&gt;
+----------+------------+
| name     | birth      |
+----------+------------+
| Puffball | 1999-03-30 |
| Chirpy   | 1998-09-11 |
| Whistler | 1997-12-09 |
| Slim     | 1996-04-29 |
| Claws    | 1994-03-17 |
| Fluffy   | 1993-02-04 |
| Fang     | 1990-08-27 |
| Bowser   | 1989-08-31 |
| Buffy    | 1989-05-13 |
+----------+------------+
&lt;/pre&gt;You can sort on multiple columns, and you can sort different           columns in different directions. For example, to sort by type           of animal in ascending order, then by birth date within animal           type in descending order (youngest animals first), use the           following query:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, species, birth FROM pet&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;ORDER BY species, birth DESC;&lt;/code&gt;&lt;/strong&gt;
+----------+---------+------------+
| name     | species | birth      |
+----------+---------+------------+
| Chirpy   | bird    | 1998-09-11 |
| Whistler | bird    | 1997-12-09 |
| Claws    | cat     | 1994-03-17 |
| Fluffy   | cat     | 1993-02-04 |
| Fang     | dog     | 1990-08-27 |
| Bowser   | dog     | 1989-08-31 |
| Buffy    | dog     | 1989-05-13 |
| Puffball | hamster | 1999-03-30 |
| Slim     | snake   | 1996-04-29 |
+----------+---------+------------+
&lt;/pre&gt;Note that the &lt;code class=&quot;literal&quot;&gt;DESC&lt;/code&gt; keyword applies only to           the column name immediately preceding it           (&lt;code class=&quot;literal&quot;&gt;birth&lt;/code&gt;); it does not affect the           &lt;code class=&quot;literal&quot;&gt;species&lt;/code&gt; column sort order.</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/6660646566570483604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/sorting-rows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/6660646566570483604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/6660646566570483604'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/sorting-rows.html' title='Sorting Rows'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-8023474736087155112</id><published>2011-03-27T11:55:00.001-07:00</published><updated>2011-03-27T11:55:47.352-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Columns"/><category scheme="http://www.blogger.com/atom/ns#" term="Particular"/><category scheme="http://www.blogger.com/atom/ns#" term="Select"/><title type='text'>Selecting Particular Columns</title><content type='html'>If you do not want to see entire rows from your table, just           name the columns in which you are interested, separated by           commas. For example, if you want to know when your animals           were born, select the &lt;code class=&quot;literal&quot;&gt;name&lt;/code&gt; and           &lt;code class=&quot;literal&quot;&gt;birth&lt;/code&gt; columns:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, birth FROM pet;&lt;/code&gt;&lt;/strong&gt;
+----------+------------+
| name     | birth      |
+----------+------------+
| Fluffy   | 1993-02-04 |
| Claws    | 1994-03-17 |
| Buffy    | 1989-05-13 |
| Fang     | 1990-08-27 |
| Bowser   | 1989-08-31 |
| Chirpy   | 1998-09-11 |
| Whistler | 1997-12-09 |
| Slim     | 1996-04-29 |
| Puffball | 1999-03-30 |
+----------+------------+
&lt;/pre&gt;To find out who owns pets, use this query:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT owner FROM pet;&lt;/code&gt;&lt;/strong&gt;
+--------+
| owner  |
+--------+
| Harold |
| Gwen   |
| Harold |
| Benny  |
| Diane  |
| Gwen   |
| Gwen   |
| Benny  |
| Diane  |
+--------+
&lt;/pre&gt;&lt;a href=&quot;&quot; name=&quot;id424935&quot;&gt;&lt;/a&gt;           Notice that the query simply retrieves the           &lt;code class=&quot;literal&quot;&gt;owner&lt;/code&gt; column from each record, and some of           them appear more than once. To minimize the output, retrieve           each unique output record just once by adding the keyword           &lt;code class=&quot;literal&quot;&gt;DISTINCT&lt;/code&gt;:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT DISTINCT owner FROM pet;&lt;/code&gt;&lt;/strong&gt;
+--------+
| owner  |
+--------+
| Benny  |
| Diane  |
| Gwen   |
| Harold |
+--------+
&lt;/pre&gt;You can use a &lt;code class=&quot;literal&quot;&gt;WHERE&lt;/code&gt; clause to combine row           selection with column selection. For example, to get birth           dates for dogs and cats only, use this query:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT name, species, birth FROM pet&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;WHERE species = &#39;dog&#39; OR species = &#39;cat&#39;;&lt;/code&gt;&lt;/strong&gt;
+--------+---------+------------+
| name   | species | birth      |
+--------+---------+------------+
| Fluffy | cat     | 1993-02-04 |
| Claws  | cat     | 1994-03-17 |
| Buffy  | dog     | 1989-05-13 |
| Fang   | dog     | 1990-08-27 |
| Bowser | dog     | 1989-08-31 |
+--------+---------+------------+
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/8023474736087155112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/selecting-particular-columns.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8023474736087155112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8023474736087155112'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/selecting-particular-columns.html' title='Selecting Particular Columns'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-1378160853123611543</id><published>2011-03-27T11:54:00.001-07:00</published><updated>2011-03-27T11:54:43.419-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data"/><category scheme="http://www.blogger.com/atom/ns#" term="Select"/><title type='text'>Selecting All Data</title><content type='html'>As shown in the preceding section, it is easy to retrieve an           entire table. Just omit the &lt;code class=&quot;literal&quot;&gt;WHERE&lt;/code&gt; clause           from the &lt;code class=&quot;literal&quot;&gt;SELECT&lt;/code&gt; statement. But typically           you don&#39;t want to see the entire table, particularly when it           becomes large. Instead, you&#39;re usually more interested in           answering a particular question, in which case you specify           some constraints on the information you want. Let&#39;s look at           some selection queries in terms of questions about your pets           that they answer.         &lt;br /&gt;
You can select only particular rows from your table. For           example, if you want to verify the change that you made to           Bowser&#39;s birth date, select Bowser&#39;s record like this:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE name = &#39;Bowser&#39;;&lt;/code&gt;&lt;/strong&gt;
+--------+-------+---------+------+------------+------------+
| name   | owner | species | sex  | birth      | death      |
+--------+-------+---------+------+------------+------------+
| Bowser | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
+--------+-------+---------+------+------------+------------+
&lt;/pre&gt;The output confirms that the year is correctly recorded as           1989, not 1979.         &lt;br /&gt;
String comparisons normally are case-insensitive, so you can           specify the name as &lt;code class=&quot;literal&quot;&gt;&#39;bowser&#39;&lt;/code&gt;,           &lt;code class=&quot;literal&quot;&gt;&#39;BOWSER&#39;&lt;/code&gt;, and so forth. The query result is           the same.         &lt;br /&gt;
You can specify conditions on any column, not just           &lt;code class=&quot;literal&quot;&gt;name&lt;/code&gt;. For example, if you want to know           which animals were born during or after 1998, test the           &lt;code class=&quot;literal&quot;&gt;birth&lt;/code&gt; column:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE birth &amp;gt;= &#39;1998-1-1&#39;;&lt;/code&gt;&lt;/strong&gt;
+----------+-------+---------+------+------------+-------+
| name     | owner | species | sex  | birth      | death |
+----------+-------+---------+------+------------+-------+
| Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
| Puffball | Diane | hamster | f    | 1999-03-30 | NULL  |
+----------+-------+---------+------+------------+-------+
&lt;/pre&gt;You can combine conditions, for example, to locate female           dogs:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE species = &#39;dog&#39; AND sex = &#39;f&#39;;&lt;/code&gt;&lt;/strong&gt;
+-------+--------+---------+------+------------+-------+
| name  | owner  | species | sex  | birth      | death |
+-------+--------+---------+------+------------+-------+
| Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
+-------+--------+---------+------+------------+-------+
&lt;/pre&gt;The preceding query uses the &lt;code class=&quot;literal&quot;&gt;AND&lt;/code&gt; logical           operator. There is also an &lt;code class=&quot;literal&quot;&gt;OR&lt;/code&gt; operator:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE species = &#39;snake&#39; OR species = &#39;bird&#39;;&lt;/code&gt;&lt;/strong&gt;
+----------+-------+---------+------+------------+-------+
| name     | owner | species | sex  | birth      | death |
+----------+-------+---------+------+------------+-------+
| Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
| Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL  |
| Slim     | Benny | snake   | m    | 1996-04-29 | NULL  |
+----------+-------+---------+------+------------+-------+
&lt;/pre&gt;&lt;code class=&quot;literal&quot;&gt;AND&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;OR&lt;/code&gt; may be           intermixed, although &lt;code class=&quot;literal&quot;&gt;AND&lt;/code&gt; has higher           precedence than &lt;code class=&quot;literal&quot;&gt;OR&lt;/code&gt;. If you use both           operators, it is a good idea to use parentheses to indicate           explicitly how conditions should be grouped:         &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM pet WHERE (species = &#39;cat&#39; AND sex = &#39;m&#39;)&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;OR (species = &#39;dog&#39; AND sex = &#39;f&#39;);&lt;/code&gt;&lt;/strong&gt;
+-------+--------+---------+------+------------+-------+
| name  | owner  | species | sex  | birth      | death |
+-------+--------+---------+------+------------+-------+
| Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
| Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
+-------+--------+---------+------+------------+-------+
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/1378160853123611543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/selecting-all-data.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/1378160853123611543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/1378160853123611543'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/selecting-all-data.html' title='Selecting All Data'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-902574332096116245</id><published>2011-03-27T11:53:00.000-07:00</published><updated>2011-03-27T11:53:32.943-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Retiriev"/><category scheme="http://www.blogger.com/atom/ns#" term="Table"/><title type='text'>Retrieving Information from a Table</title><content type='html'>vThe &lt;code class=&quot;literal&quot;&gt;SELECT&lt;/code&gt; statement is used to pull         information from a table. The general form of the statement is:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;SELECT &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;what_to_select&lt;/code&gt;&lt;/i&gt;
FROM &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;which_table&lt;/code&gt;&lt;/i&gt;
WHERE &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;conditions_to_satisfy&lt;/code&gt;&lt;/i&gt;;
&lt;/pre&gt;&lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;what_to_select&lt;/code&gt;&lt;/i&gt; indicates what you         want to see. This can be a list of columns, or         &lt;code class=&quot;literal&quot;&gt;*&lt;/code&gt; to indicate “&lt;span class=&quot;quote&quot;&gt;all columns.&lt;/span&gt;”         &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;which_table&lt;/code&gt;&lt;/i&gt; indicates the table from         which you want to retrieve data. The &lt;code class=&quot;literal&quot;&gt;WHERE&lt;/code&gt;         clause is optional. If it is present,         &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;conditions_to_satisfy&lt;/code&gt;&lt;/i&gt; specifies one         or more conditions that rows must satisfy to qualify for         retrieval.</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/902574332096116245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/retrieving-information-from-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/902574332096116245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/902574332096116245'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/retrieving-information-from-table.html' title='Retrieving Information from a Table'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-8154594198865093708</id><published>2011-03-27T11:51:00.001-07:00</published><updated>2011-03-27T11:51:48.684-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Load Data"/><category scheme="http://www.blogger.com/atom/ns#" term="Table"/><title type='text'>Loading Data into a Table</title><content type='html'>After creating your table, you need to populate it. The         &lt;code class=&quot;literal&quot;&gt;LOAD DATA&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;INSERT&lt;/code&gt;         statements are useful for this.       &lt;br /&gt;
Suppose that your pet records can be described as shown here.         (Observe that MySQL expects dates in         &lt;code class=&quot;literal&quot;&gt;&#39;YYYY-MM-DD&#39;&lt;/code&gt; format; this may be different         from what you are used to.)       &lt;br /&gt;
&lt;div class=&quot;informaltable&quot;&gt;&lt;table border=&quot;1&quot;&gt;&lt;colgroup&gt;&lt;col&gt;&lt;/col&gt;&lt;col&gt;&lt;/col&gt;&lt;col&gt;&lt;/col&gt;&lt;col&gt;&lt;/col&gt;&lt;col&gt;&lt;/col&gt;&lt;col&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;span class=&quot;bold&quot;&gt;&lt;strong&gt;name&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;bold&quot;&gt;&lt;strong&gt;owner&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;bold&quot;&gt;&lt;strong&gt;species&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;bold&quot;&gt;&lt;strong&gt;sex&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;bold&quot;&gt;&lt;strong&gt;birth&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;bold&quot;&gt;&lt;strong&gt;death&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Fluffy&lt;/td&gt;&lt;td&gt;Harold&lt;/td&gt;&lt;td&gt;cat&lt;/td&gt;&lt;td&gt;f&lt;/td&gt;&lt;td&gt;1993-02-04&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Claws&lt;/td&gt;&lt;td&gt;Gwen&lt;/td&gt;&lt;td&gt;cat&lt;/td&gt;&lt;td&gt;m&lt;/td&gt;&lt;td&gt;1994-03-17&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Buffy&lt;/td&gt;&lt;td&gt;Harold&lt;/td&gt;&lt;td&gt;dog&lt;/td&gt;&lt;td&gt;f&lt;/td&gt;&lt;td&gt;1989-05-13&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Fang&lt;/td&gt;&lt;td&gt;Benny&lt;/td&gt;&lt;td&gt;dog&lt;/td&gt;&lt;td&gt;m&lt;/td&gt;&lt;td&gt;1990-08-27&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Bowser&lt;/td&gt;&lt;td&gt;Diane&lt;/td&gt;&lt;td&gt;dog&lt;/td&gt;&lt;td&gt;m&lt;/td&gt;&lt;td&gt;1979-08-31&lt;/td&gt;&lt;td&gt;1995-07-29&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Chirpy&lt;/td&gt;&lt;td&gt;Gwen&lt;/td&gt;&lt;td&gt;bird&lt;/td&gt;&lt;td&gt;f&lt;/td&gt;&lt;td&gt;1998-09-11&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Whistler&lt;/td&gt;&lt;td&gt;Gwen&lt;/td&gt;&lt;td&gt;bird&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;1997-12-09&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Slim&lt;/td&gt;&lt;td&gt;Benny&lt;/td&gt;&lt;td&gt;snake&lt;/td&gt;&lt;td&gt;m&lt;/td&gt;&lt;td&gt;1996-04-29&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;Because you are beginning with an empty table, an easy way to         populate it is to create a text file containing a row for each         of your animals, then load the contents of the file into the         table with a single statement.       &lt;br /&gt;
You could create a text file &lt;code class=&quot;filename&quot;&gt;pet.txt&lt;/code&gt;         containing one record per line, with values separated by tabs,         and given in the order in which the columns were listed in the         &lt;code class=&quot;literal&quot;&gt;CREATE TABLE&lt;/code&gt; statement. For missing values         (such as unknown sexes or death dates for animals that are still         living), you can use &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; values. To         represent these in your text file, use &lt;code class=&quot;literal&quot;&gt;\N&lt;/code&gt;         (backslash, capital-N). For example, the record for Whistler the         bird would look like this (where the whitespace between values         is a single tab character):       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;Whistler        Gwen    bird    \N      1997-12-09      \N
&lt;/pre&gt;To load the text file &lt;code class=&quot;filename&quot;&gt;pet.txt&lt;/code&gt; into the         &lt;code class=&quot;literal&quot;&gt;pet&lt;/code&gt; table, use this command:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;LOAD DATA LOCAL INFILE &#39;/path/pet.txt&#39; INTO TABLE pet;&lt;/code&gt;&lt;/strong&gt;
&lt;/pre&gt;Note that if you created the file on Windows with an editor that         uses &lt;code class=&quot;literal&quot;&gt;\r\n&lt;/code&gt; as a line terminator, you should         use:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;LOAD DATA LOCAL INFILE &#39;/path/pet.txt&#39; INTO TABLE pet&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;LINES TERMINATED BY &#39;\r\n&#39;;&lt;/code&gt;&lt;/strong&gt;
&lt;/pre&gt;(On an Apple machine running OS X, you would likely want to use         &lt;code class=&quot;literal&quot;&gt;LINES TERMINATED BY &#39;\r&#39;&lt;/code&gt;.)       &lt;br /&gt;
You can specify the column value separator and end of line         marker explicitly in the &lt;code class=&quot;literal&quot;&gt;LOAD DATA&lt;/code&gt; statement         if you wish, but the defaults are tab and linefeed. These are         sufficient for the statement to read the file         &lt;code class=&quot;filename&quot;&gt;pet.txt&lt;/code&gt; properly.&lt;br /&gt;
&lt;br /&gt;
When you want to add new records one at a time, the         &lt;code class=&quot;literal&quot;&gt;INSERT&lt;/code&gt; statement is useful. In its simplest         form, you supply values for each column, in the order in which         the columns were listed in the &lt;code class=&quot;literal&quot;&gt;CREATE TABLE&lt;/code&gt;         statement. Suppose that Diane gets a new hamster named         “&lt;span class=&quot;quote&quot;&gt;Puffball.&lt;/span&gt;” You could add a new record using an         &lt;code class=&quot;literal&quot;&gt;INSERT&lt;/code&gt; statement like this:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;INSERT INTO pet&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;VALUES (&#39;Puffball&#39;,&#39;Diane&#39;,&#39;hamster&#39;,&#39;f&#39;,&#39;1999-03-30&#39;,NULL);&lt;/code&gt;&lt;/strong&gt;
&lt;/pre&gt;&lt;br /&gt;
Note that string and date values are specified as quoted strings         here. Also, with &lt;code class=&quot;literal&quot;&gt;INSERT&lt;/code&gt;, you can insert         &lt;code class=&quot;literal&quot;&gt;NULL&lt;/code&gt; directly to represent a missing value.         You do not use &lt;code class=&quot;literal&quot;&gt;\N&lt;/code&gt; like you do with         &lt;code class=&quot;literal&quot;&gt;LOAD DATA&lt;/code&gt;.       &lt;br /&gt;
From this example, you should be able to see that there would be         a lot more typing involved to load your records initially using         several &lt;code class=&quot;literal&quot;&gt;INSERT&lt;/code&gt; statements rather than a         single &lt;code class=&quot;literal&quot;&gt;LOAD DATA&lt;/code&gt; statement.</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/8154594198865093708/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/loading-data-into-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8154594198865093708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8154594198865093708'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/loading-data-into-table.html' title='Loading Data into a Table'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-8630504708829356206</id><published>2011-03-27T11:49:00.000-07:00</published><updated>2011-03-27T11:49:18.994-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Create"/><category scheme="http://www.blogger.com/atom/ns#" term="Table"/><title type='text'>Creating a Table</title><content type='html'>Creating the database is the easy part, but at this point it&#39;s         empty, as &lt;code class=&quot;literal&quot;&gt;SHOW TABLES&lt;/code&gt; tells you:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SHOW TABLES;&lt;/code&gt;&lt;/strong&gt;
Empty set (0.00 sec)
&lt;/pre&gt;The harder part is deciding what the structure of your database         should be: what tables you need and what columns should be in         each of them.&lt;br /&gt;
&lt;br /&gt;
You can probably think of other types of information that would         be useful in the &lt;code class=&quot;literal&quot;&gt;pet&lt;/code&gt; table, but the ones         identified so far are sufficient: name, owner, species, sex,         birth, and death.       &lt;br /&gt;
Use a &lt;code class=&quot;literal&quot;&gt;CREATE TABLE&lt;/code&gt; statement to specify the         layout of your table:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);&lt;/code&gt;&lt;/strong&gt;
&lt;/pre&gt;&lt;code class=&quot;literal&quot;&gt;VARCHAR&lt;/code&gt; is a good choice for the         &lt;code class=&quot;literal&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;literal&quot;&gt;owner&lt;/code&gt;, and         &lt;code class=&quot;literal&quot;&gt;species&lt;/code&gt; columns because the column values         vary in length. The lengths in those column definitions need not         all be the same, and need not be &lt;code class=&quot;literal&quot;&gt;20&lt;/code&gt;. You can         pick any length from &lt;code class=&quot;literal&quot;&gt;1&lt;/code&gt; to         &lt;code class=&quot;literal&quot;&gt;255&lt;/code&gt;, whatever seems most reasonable to you.         (If you make a poor choice and it turns out later that you need         a longer field, MySQL provides an &lt;code class=&quot;literal&quot;&gt;ALTER TABLE&lt;/code&gt;         statement.)       &lt;br /&gt;
Several types of values can be chosen to represent sex in animal         records, such as &lt;code class=&quot;literal&quot;&gt;&#39;m&#39;&lt;/code&gt; and         &lt;code class=&quot;literal&quot;&gt;&#39;f&#39;&lt;/code&gt;, or perhaps &lt;code class=&quot;literal&quot;&gt;&#39;male&#39;&lt;/code&gt; and         &lt;code class=&quot;literal&quot;&gt;&#39;female&#39;&lt;/code&gt;. It is simplest to use the single         characters &lt;code class=&quot;literal&quot;&gt;&#39;m&#39;&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;&#39;f&#39;&lt;/code&gt;.       &lt;br /&gt;
The use of the &lt;code class=&quot;literal&quot;&gt;DATE&lt;/code&gt; data type for the         &lt;code class=&quot;literal&quot;&gt;birth&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;death&lt;/code&gt; columns is         a fairly obvious choice.       &lt;br /&gt;
Once you have created a table, &lt;code class=&quot;literal&quot;&gt;SHOW TABLES&lt;/code&gt;         should produce some output:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SHOW TABLES;&lt;/code&gt;&lt;/strong&gt;
+---------------------+
| Tables in menagerie |
+---------------------+
| pet                 |
+---------------------+
&lt;/pre&gt;To verify that your table was created the way you expected, use         a &lt;code class=&quot;literal&quot;&gt;DESCRIBE&lt;/code&gt; statement:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;DESCRIBE pet;&lt;/code&gt;&lt;/strong&gt;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name    | varchar(20) | YES  |     | NULL    |       |
| owner   | varchar(20) | YES  |     | NULL    |       |
| species | varchar(20) | YES  |     | NULL    |       |
| sex     | char(1)     | YES  |     | NULL    |       |
| birth   | date        | YES  |     | NULL    |       |
| death   | date        | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
&lt;/pre&gt;You can use &lt;code class=&quot;literal&quot;&gt;DESCRIBE&lt;/code&gt; any time, for example,         if you forget the names of the columns in your table or what         types they have.</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/8630504708829356206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/creating-table.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8630504708829356206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8630504708829356206'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/creating-table.html' title='Creating a Table'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-8949189478700579245</id><published>2011-03-27T11:47:00.000-07:00</published><updated>2011-03-28T18:47:52.403-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Create"/><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><category scheme="http://www.blogger.com/atom/ns#" term="Select"/><title type='text'>Creating and Selecting a Database</title><content type='html'>If the administrator creates your database for you when setting         up your permissions, you can begin using it. Otherwise, you need         to create it yourself:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;CREATE DATABASE menagerie;&lt;/code&gt;&lt;/b&gt;
&lt;/pre&gt;Under Unix, database names are case sensitive (unlike SQL         keywords), so you must always refer to your database as         &lt;code class=&quot;literal&quot;&gt;menagerie&lt;/code&gt;, not as         &lt;code class=&quot;literal&quot;&gt;Menagerie&lt;/code&gt;, &lt;code class=&quot;literal&quot;&gt;MENAGERIE&lt;/code&gt;, or         some other variant. This is also true for table names. (Under         Windows, this restriction does not apply, although you must         refer to databases and tables using the same lettercase         throughout a given query. However, for a variety of reasons, our         recommended best practice is always to use the same lettercase         that was used when the database was created.)&lt;br /&gt;
&lt;br /&gt;
Creating a database does not select it for use; you must do that         explicitly. To make &lt;code class=&quot;literal&quot;&gt;menagerie&lt;/code&gt; the current         database, use this command:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;USE menagerie&lt;/code&gt;&lt;/b&gt;
Database changed
&lt;/pre&gt;Your database needs to be created only once, but you must select         it for use each time you begin a &lt;b class=&quot;command&quot;&gt;mysql&lt;/b&gt;         session. You can do this by issuing a &lt;code class=&quot;literal&quot;&gt;USE&lt;/code&gt;         statement as shown in the example. Alternatively, you can select         the database on the command line when you invoke         &lt;b class=&quot;command&quot;&gt;mysql&lt;/b&gt;. Just specify its name after any         connection parameters that you might need to provide. For         example:       &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;shell&amp;gt; &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;mysql -h &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;host&lt;/code&gt;&lt;/i&gt; -u &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;user&lt;/code&gt;&lt;/i&gt; -p menagerie&lt;/code&gt;&lt;/b&gt;
Enter password: &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;********&lt;/code&gt;&lt;/b&gt;
&lt;/pre&gt;Note that &lt;code class=&quot;literal&quot;&gt;menagerie&lt;/code&gt; in the command just shown         is &lt;span class=&quot;bold&quot;&gt;&lt;b&gt;not&lt;/b&gt;&lt;/span&gt; your password. If you         want to supply your password on the command line after the         &lt;code class=&quot;literal&quot;&gt;-p&lt;/code&gt; option, you must do so with no intervening         space (for example, as &lt;code class=&quot;literal&quot;&gt;-pmypassword&lt;/code&gt;, not as         &lt;code class=&quot;literal&quot;&gt;-p mypassword&lt;/code&gt;). However, putting your         password on the command line is not recommended, because doing         so exposes it to snooping by other users logged in on your         machine.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;i&gt;other:&lt;/i&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;gsc-webResult gsc-result&quot;&gt;&lt;div class=&quot;gs-webResult gs-result&quot;&gt;&lt;div class=&quot;gs-title&quot;&gt;&lt;a class=&quot;gs-title&quot; href=&quot;http://en.wikipedia.org/wiki/Database&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Database&lt;/b&gt; - Wikipedia, the free encyclopedia&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;gs-snippet&quot;&gt;A &lt;b&gt;database&lt;/b&gt;  is a system intended to organize, store, and retrieve large amounts    of data easily. It consists of an organized collection of data for one  or &lt;b&gt;...&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;gs-visibleUrl gs-visibleUrl-short&quot; style=&quot;color: red;&quot;&gt;en.wikipedia.org&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;gsc-webResult gsc-result&quot;&gt;&lt;div class=&quot;gs-webResult gs-result&quot;&gt;&lt;div class=&quot;gs-title&quot;&gt;&lt;a class=&quot;gs-title&quot; href=&quot;http://search.ebscohost.com/&quot; target=&quot;_blank&quot;&gt;EBSCOhost - world&#39;s foremost premium research &lt;b&gt;database&lt;/b&gt; service&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;gs-snippet&quot;&gt;EBSCOhost  (ebscohost.com) serves thousands of libraries and other institutions    with premium content in every subject area. Free LISTA:  LibraryResearch.com.&lt;/div&gt;&lt;div class=&quot;gs-visibleUrl gs-visibleUrl-short&quot; style=&quot;color: red;&quot;&gt;search.ebscohost.com&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;gsc-webResult gsc-result&quot;&gt;&lt;div class=&quot;gs-webResult gs-result&quot;&gt;&lt;div class=&quot;gs-title&quot;&gt;&lt;a class=&quot;gs-title&quot; href=&quot;http://www.webopedia.com/TERM/D/database.html&quot; target=&quot;_blank&quot;&gt;What is &lt;b&gt;database&lt;/b&gt;? - A Word Definition From the Webopedia Computer &lt;b&gt;...&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;gs-snippet&quot;&gt;This page describes the term &lt;b&gt;database&lt;/b&gt; and lists other pages on the Web where you   can find additional information.&lt;/div&gt;&lt;div class=&quot;gs-visibleUrl gs-visibleUrl-short&quot; style=&quot;color: red;&quot;&gt;www.webopedia.com&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;gs-title&quot;&gt;&lt;a class=&quot;gs-title&quot; href=&quot;http://www.mysql.com/&quot; target=&quot;_blank&quot;&gt;MySQL :: The world&#39;s most popular open source &lt;b&gt;database&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;gs-snippet&quot;&gt;The software&#39;s official homepage with news, downloads and documentation.&lt;/div&gt;&lt;div class=&quot;gs-visibleUrl gs-visibleUrl-short&quot;&gt;www.mysql.com&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/8949189478700579245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/creating-and-selecting-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8949189478700579245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/8949189478700579245'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/creating-and-selecting-database.html' title='Creating and Selecting a Database'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-6430127803614088954</id><published>2011-03-27T11:44:00.000-07:00</published><updated>2011-03-27T11:44:11.997-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Prompt"/><category scheme="http://www.blogger.com/atom/ns#" term="Queries"/><title type='text'>Entering Queries</title><content type='html'>Here&#39;s a simple command that asks the server to tell you its       version number and the current date. Type it in as shown here       following the &lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt; prompt and press Enter:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT VERSION(), CURRENT_DATE;&lt;/code&gt;&lt;/strong&gt;
+------------+--------------+
| VERSION()  | CURRENT_DATE |
+------------+--------------+
| 4.1.14-Max | 2005-09-03   |
+------------+--------------+
1 row in set (0.01 sec)
mysql&amp;gt;
&lt;/pre&gt;This query illustrates several things about       &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt;:     &lt;br /&gt;
&lt;div class=&quot;itemizedlist&quot;&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li&gt;           A command normally consists of an SQL statement followed by a           semicolon. (There are some exceptions where a semicolon may be           omitted. &lt;code class=&quot;literal&quot;&gt;QUIT&lt;/code&gt;, mentioned earlier, is one of           them. We&#39;ll get to others later.)         &lt;/li&gt;
&lt;li&gt;           When you issue a command, &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; sends it to           the server for execution and displays the results, then prints           another &lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt; prompt to indicate that           it is ready for another command.         &lt;/li&gt;
&lt;li&gt;           &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; displays query output in tabular form           (rows and columns). The first row contains labels for the           columns. The rows following are the query results. Normally,           column labels are the names of the columns you fetch from           database tables. If you&#39;re retrieving the value of an           expression rather than a table column (as in the example just           shown), &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; labels the column using the           expression itself.         &lt;/li&gt;
&lt;li&gt;           &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; shows how many rows were returned and           how long the query took to execute, which gives you a rough           idea of server performance. These values are imprecise because           they represent wall clock time (not CPU or machine time), and           because they are affected by factors such as server load and           network latency. (For brevity, the “&lt;span class=&quot;quote&quot;&gt;rows in set&lt;/span&gt;”           line is sometimes not shown in the remaining examples in this           chapter.)         &lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;Keywords may be entered in any lettercase. The following queries       are equivalent:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT VERSION(), CURRENT_DATE;&lt;/code&gt;&lt;/strong&gt;
mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;select version(), current_date;&lt;/code&gt;&lt;/strong&gt;
mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SeLeCt vErSiOn(), current_DATE;&lt;/code&gt;&lt;/strong&gt;
&lt;/pre&gt;Here&#39;s another query. It demonstrates that you can use       &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; as a simple calculator:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT SIN(PI()/4), (4+1)*5;&lt;/code&gt;&lt;/strong&gt;
+-------------+---------+
| SIN(PI()/4) | (4+1)*5 |
+-------------+---------+
|    0.707107 |      25 |
+-------------+---------+
&lt;/pre&gt;The queries shown thus far have been relatively short, single-line       statements. You can even enter multiple statements on a single       line. Just end each one with a semicolon:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT VERSION(); SELECT NOW();&lt;/code&gt;&lt;/strong&gt;
+------------+
| VERSION()  |
+------------+
| 4.1.14-Max |
+------------+

+---------------------+
| NOW()               |
+---------------------+
| 2005-09-03 12:27:16 |
+---------------------+
&lt;/pre&gt;A command need not be given all on a single line, so lengthy       commands that require several lines are not a problem.       &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; determines where your statement ends by       looking for the terminating semicolon, not by looking for the end       of the input line. (In other words, &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt;       accepts free-format input: it collects input lines but does not       execute them until it sees the semicolon.)     &lt;br /&gt;
Here&#39;s a simple multiple-line statement:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;USER()&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;,&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;CURRENT_DATE;&lt;/code&gt;&lt;/strong&gt;
+---------------+--------------+
| USER()        | CURRENT_DATE |
+---------------+--------------+
| jon@localhost | 2005-09-03   |
+---------------+--------------+
&lt;/pre&gt;In this example, notice how the prompt changes from       &lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt; to &lt;code class=&quot;literal&quot;&gt;-&amp;gt;&lt;/code&gt; after you       enter the first line of a multiple-line query. This is how       &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; indicates that it has not yet seen a       complete statement and is waiting for the rest. The prompt is your       friend, because it provides valuable feedback. If you use that       feedback, you can always be aware of what &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt;       is waiting for.     &lt;br /&gt;
If you decide you do not want to execute a command that you are in       the process of entering, cancel it by typing       &lt;code class=&quot;literal&quot;&gt;\c&lt;/code&gt;:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;USER()&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;\c&lt;/code&gt;&lt;/strong&gt;
mysql&amp;gt;
&lt;/pre&gt;Here, too, notice the prompt. It switches back to       &lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt; after you type &lt;code class=&quot;literal&quot;&gt;\c&lt;/code&gt;,       providing feedback to indicate that &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; is       ready for a new command.     &lt;br /&gt;
The following table shows each of the prompts you may see and       summarizes what they mean about the state that       &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; is in:     &lt;br /&gt;
&lt;a href=&quot;&quot; name=&quot;id421804&quot;&gt;&lt;/a&gt;&lt;div class=&quot;informaltable&quot;&gt;&lt;table border=&quot;1&quot;&gt;&lt;colgroup&gt;&lt;col&gt;&lt;/col&gt;&lt;col&gt;&lt;/col&gt;&lt;/colgroup&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;span class=&quot;bold&quot;&gt;&lt;strong&gt;Prompt&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;bold&quot;&gt;&lt;strong&gt;Meaning&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Ready for new command.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;literal&quot;&gt;-&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Waiting for next line of multiple-line command.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;literal&quot;&gt;&#39;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Waiting for next line, waiting for completion of a string that began               with a single quote (‘&lt;code class=&quot;literal&quot;&gt;&#39;&lt;/code&gt;’).&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;literal&quot;&gt;&quot;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Waiting for next line, waiting for completion of a string that began               with a double quote (‘&lt;code class=&quot;literal&quot;&gt;&quot;&lt;/code&gt;’).&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;literal&quot;&gt;`&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Waiting for next line, waiting for completion of an identifier that               began with a backtick               (‘&lt;code class=&quot;literal&quot;&gt;`&lt;/code&gt;’).&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code class=&quot;literal&quot;&gt;/*&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Waiting for next line, waiting for completion of a comment that began               with &lt;code class=&quot;literal&quot;&gt;/*&lt;/code&gt;.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;The &lt;code class=&quot;literal&quot;&gt;`&amp;gt;&lt;/code&gt; prompt was implemented MySQL 4.0.16.       The &lt;code class=&quot;literal&quot;&gt;/*&amp;gt;&lt;/code&gt; prompt was implemented in MySQL       4.1.12.     &lt;br /&gt;
Multiple-line statements commonly occur by accident when you       intend to issue a command on a single line, but forget the       terminating semicolon. In this case, &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt;       waits for more input:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT USER()&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt;
&lt;/pre&gt;If this happens to you (you think you&#39;ve entered a statement but       the only response is a &lt;code class=&quot;literal&quot;&gt;-&amp;gt;&lt;/code&gt; prompt), most       likely &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; is waiting for the semicolon. If       you don&#39;t notice what the prompt is telling you, you might sit       there for a while before realizing what you need to do. Enter a       semicolon to complete the statement, and &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt;       executes it:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT USER()&lt;/code&gt;&lt;/strong&gt;
    -&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;;&lt;/code&gt;&lt;/strong&gt;
+---------------+
| USER()        |
+---------------+
| jon@localhost |
+---------------+
&lt;/pre&gt;The &lt;code class=&quot;literal&quot;&gt;&#39;&amp;gt;&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;&quot;&amp;gt;&lt;/code&gt; prompts       occur during string collection (another way of saying that MySQL       is waiting for completion of a string). In MySQL, you can write       strings surrounded by either ‘&lt;code class=&quot;literal&quot;&gt;&#39;&lt;/code&gt;’ or       ‘&lt;code class=&quot;literal&quot;&gt;&quot;&lt;/code&gt;’ characters (for example,       &lt;code class=&quot;literal&quot;&gt;&#39;hello&#39;&lt;/code&gt; or &lt;code class=&quot;literal&quot;&gt;&quot;goodbye&quot;&lt;/code&gt;), and       &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; lets you enter strings that span multiple       lines. When you see a &lt;code class=&quot;literal&quot;&gt;&#39;&amp;gt;&lt;/code&gt; or       &lt;code class=&quot;literal&quot;&gt;&quot;&amp;gt;&lt;/code&gt; prompt, it means that you have entered a       line containing a string that begins with a       ‘&lt;code class=&quot;literal&quot;&gt;&#39;&lt;/code&gt;’ or       ‘&lt;code class=&quot;literal&quot;&gt;&quot;&lt;/code&gt;’ quote character, but have not       yet entered the matching quote that terminates the string. This       often indicates that you have inadvertently left out a quote       character. For example:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM my_table WHERE name = &#39;Smith AND age &amp;lt; 30;&lt;/code&gt;&lt;/strong&gt;
    &#39;&amp;gt;
&lt;/pre&gt;If you enter this &lt;code class=&quot;literal&quot;&gt;SELECT&lt;/code&gt; statement, then press       &lt;span&gt;&lt;strong class=&quot;keycap&quot;&gt;Enter&lt;/strong&gt;&lt;/span&gt; and wait for the result, nothing happens.       Instead of wondering why this query takes so long, notice the clue       provided by the &lt;code class=&quot;literal&quot;&gt;&#39;&amp;gt;&lt;/code&gt; prompt. It tells you that       &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; expects to see the rest of an       unterminated string. (Do you see the error in the statement? The       string &lt;code class=&quot;literal&quot;&gt;&#39;Smith&lt;/code&gt; is missing the second single       quote mark.)     &lt;br /&gt;
At this point, what do you do? The simplest thing is to cancel the       command. However, you cannot just type &lt;code class=&quot;literal&quot;&gt;\c&lt;/code&gt; in       this case, because &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; interprets it as part       of the string that it is collecting. Instead, enter the closing       quote character (so &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; knows you&#39;ve finished       the string), then type &lt;code class=&quot;literal&quot;&gt;\c&lt;/code&gt;:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;mysql&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;SELECT * FROM my_table WHERE name = &#39;Smith AND age &amp;lt; 30;&lt;/code&gt;&lt;/strong&gt;
    &#39;&amp;gt; &lt;strong class=&quot;userinput&quot;&gt;&lt;code&gt;&#39;\c&lt;/code&gt;&lt;/strong&gt;
mysql&amp;gt;
&lt;/pre&gt;The prompt changes back to &lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt;,       indicating that &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; is ready for a new       command.     &lt;br /&gt;
The &lt;code class=&quot;literal&quot;&gt;`&amp;gt;&lt;/code&gt; prompt is similar to the       &lt;code class=&quot;literal&quot;&gt;&#39;&amp;gt;&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;&quot;&amp;gt;&lt;/code&gt; prompts, but       indicates that you have begun but not completed a backtick-quoted       identifier.     &lt;br /&gt;
It is important to know what the &lt;code class=&quot;literal&quot;&gt;&#39;&amp;gt;&lt;/code&gt;,       &lt;code class=&quot;literal&quot;&gt;&quot;&amp;gt;&lt;/code&gt;, and &lt;code class=&quot;literal&quot;&gt;`&amp;gt;&lt;/code&gt; prompts       signify, because if you mistakenly enter an unterminated string,       any further lines you type appear to be ignored by       &lt;span&gt;&lt;strong class=&quot;command&quot;&gt;mysql&lt;/strong&gt;&lt;/span&gt; — including a line containing       &lt;code class=&quot;literal&quot;&gt;QUIT&lt;/code&gt;. This can be quite confusing, especially       if you do not know that you need to supply the terminating quote       before you can cancel the current command.</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/6430127803614088954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/entering-queries.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/6430127803614088954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/6430127803614088954'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/entering-queries.html' title='Entering Queries'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-740204580390955820</id><published>2011-03-27T11:41:00.000-07:00</published><updated>2011-03-27T11:45:19.003-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Connect"/><category scheme="http://www.blogger.com/atom/ns#" term="Disconnect"/><category scheme="http://www.blogger.com/atom/ns#" term="Server"/><title type='text'>Connecting to and Disconnecting from the Server</title><content type='html'>To connect to the server, you will usually need to provide a MySQL       user name when you invoke &lt;b class=&quot;command&quot;&gt;mysql&lt;/b&gt; and, most       likely, a password. If the server runs on a machine other than the       one where you log in, you will also need to specify a host name.       Contact your administrator to find out what connection parameters       you should use to connect (that is, what host, user name, and       password to use). Once you know the proper parameters, you should       be able to connect like this:&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;shell&amp;gt; &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;mysql -h &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;host&lt;/code&gt;&lt;/i&gt; -u &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;user&lt;/code&gt;&lt;/i&gt; -p&lt;/code&gt;&lt;/b&gt;
Enter password: &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;********&lt;/code&gt;&lt;/b&gt;
&lt;/pre&gt;&lt;code class=&quot;literal&quot;&gt;host&lt;/code&gt; and &lt;code class=&quot;literal&quot;&gt;user&lt;/code&gt; represent the       host name where your MySQL server is running and the user name of       your MySQL account. Substitute appropriate values for your setup.       The &lt;code class=&quot;literal&quot;&gt;********&lt;/code&gt; represents your password; enter it       when &lt;b class=&quot;command&quot;&gt;mysql&lt;/b&gt; displays the &lt;code class=&quot;literal&quot;&gt;Enter       password:&lt;/code&gt; prompt.     &lt;br /&gt;
If that works, you should see some introductory information       followed by a &lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt; prompt:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;shell&amp;gt; &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;mysql -h &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;host&lt;/code&gt;&lt;/i&gt; -u &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;user&lt;/code&gt;&lt;/i&gt; -p&lt;/code&gt;&lt;/b&gt;
Enter password: &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;********&lt;/code&gt;&lt;/b&gt;
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 25338 to server version: 4.1.22-standard

Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the buffer.

mysql&amp;gt;
&lt;/pre&gt;The &lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt; prompt tells you that       &lt;b class=&quot;command&quot;&gt;mysql&lt;/b&gt; is ready for you to enter commands.     &lt;br /&gt;
If you are logging in on the same machine that MySQL is running       on, you can omit the host, and simply use the following:     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;shell&amp;lt; &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;mysql -u &lt;i class=&quot;replaceable&quot;&gt;&lt;code&gt;user&lt;/code&gt;&lt;/i&gt; -p&lt;/code&gt;&lt;/b&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;programlisting&quot;&gt;&amp;nbsp;&lt;/pre&gt;Some MySQL installations allow users to connect as the anonymous       (unnamed) user to the server running on the local host. If this is       the case on your machine, you should be able to connect to that       server by invoking &lt;b class=&quot;command&quot;&gt;mysql&lt;/b&gt; without any options:     &lt;br /&gt;
shell&amp;gt; &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;mysql&lt;/code&gt;&lt;/b&gt;        After you have connected successfully, you can disconnect any time       by typing &lt;code class=&quot;literal&quot;&gt;QUIT&lt;/code&gt; (or &lt;code class=&quot;literal&quot;&gt;\q&lt;/code&gt;) at       the &lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt; prompt:     &lt;br /&gt;
mysql&amp;gt; &lt;b class=&quot;userinput&quot;&gt;&lt;code&gt;QUIT&lt;/code&gt;&lt;/b&gt; Bye        On Unix, you can also disconnect by pressing Control-D.     &lt;br /&gt;
Most examples in the following sections assume that you are       connected to the server. They indicate this by the       &lt;code class=&quot;literal&quot;&gt;mysql&amp;gt;&lt;/code&gt; prompt.     &lt;br /&gt;
&lt;pre class=&quot;programlisting&quot;&gt;&amp;nbsp;&lt;/pre&gt;[ &lt;a href=&quot;http://mysql-tutorial.blogspot.com/2011/03/entering-queries.html&quot;&gt;next&lt;/a&gt; ]</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/740204580390955820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/connecting-to-and-disconnecting-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/740204580390955820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/740204580390955820'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/connecting-to-and-disconnecting-from.html' title='Connecting to and Disconnecting from the Server'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-270283613534528974</id><published>2011-03-27T11:35:00.000-07:00</published><updated>2011-03-27T11:42:02.571-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Operatyng System"/><category scheme="http://www.blogger.com/atom/ns#" term="Suported"/><title type='text'>Operating Systems Supported by MySQL</title><content type='html'>MySQL has been reported to compile successfully on the following combinations of operating system and thread package. Note that for many operating systems, native thread support works only in the latest versions&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;itemizedlist&quot;&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li&gt;             AIX 4.x, 5.x with native threads.&lt;/li&gt;
&lt;li&gt;             Amiga.           &lt;/li&gt;
&lt;li&gt;             BSDI 2.x with the MIT-pthreads package. &lt;/li&gt;
&lt;li&gt;             BSDI 3.0, 3.1 and 4.x with native threads. &lt;/li&gt;
&lt;li&gt;             Digital Unix 4.x with native threads.&lt;/li&gt;
&lt;li&gt;             FreeBSD 2.x with the MIT-pthreads package. &lt;/li&gt;
&lt;li&gt;             FreeBSD 3.x and 4.x with native threads. &lt;/li&gt;
&lt;li&gt;             FreeBSD 4.x with LinuxThreads. &lt;/li&gt;
&lt;li&gt;             HP-UX 10.20 with the DCE threads or the MIT-pthreads             package. &lt;/li&gt;
&lt;li&gt;             HP-UX 11.x with the native threads.&lt;/li&gt;
&lt;li&gt;             Linux 2.0+ with LinuxThreads 0.7.1+ or             &lt;code class=&quot;literal&quot;&gt;glibc&lt;/code&gt; 2.0.7+ for various CPU             architectures.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;             Mac OS X.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;             NetBSD 1.3/1.4 Intel and NetBSD 1.3 Alpha (requires GNU             make). &lt;/li&gt;
&lt;li&gt;             Novell NetWare 6.0 and 6.5. &lt;/li&gt;
&lt;li&gt;             OpenBSD 2.5 and with native threads. OpenBSD earlier than             2.5 with the MIT-pthreads package.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;             OS/2 Warp 3, FixPack 29 and OS/2 Warp 4, FixPack 4.&lt;/li&gt;
&lt;li&gt;             SCO OpenServer 5.0.X with a recent port of the FSU Pthreads             package. &lt;/li&gt;
&lt;li&gt;             SCO Openserver 6.0.x.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;             SCO UnixWare 7.1.x.&amp;nbsp;           &lt;/li&gt;
&lt;li&gt;             SGI Irix 6.x with native threads.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;             Solaris 2.5 and above with native threads on SPARC and x86.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;             SunOS 4.x with the MIT-pthreads package.&amp;nbsp;&lt;a href=&quot;http://www.blogger.com/post-create.g?blogID=316532415128145912&quot; title=&quot;2.13.3. Solaris Notes&quot;&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;             Tru64 Unix.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;             Windows 9x, Me, NT, 2000, XP, and Windows Server 2003.&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;[ &lt;a href=&quot;http://mysql-tutorial.blogspot.com/2011/03/connecting-to-and-disconnecting-from.html&quot;&gt;next&lt;/a&gt; ]</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/270283613534528974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/operating-systems-supported-by-mysql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/270283613534528974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/270283613534528974'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/operating-systems-supported-by-mysql.html' title='Operating Systems Supported by MySQL'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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-316532415128145912.post-9198090468802971371</id><published>2011-03-27T11:26:00.000-07:00</published><updated>2011-03-27T11:35:39.036-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Install"/><category scheme="http://www.blogger.com/atom/ns#" term="Upgrade"/><title type='text'>Installing and Upgrading MySQL</title><content type='html'>Before installing MySQL, you should do the following:     &lt;br /&gt;
&lt;div class=&quot;orderedlist&quot;&gt;&lt;ol type=&quot;1&quot;&gt;&lt;li&gt;           Determine whether MySQL runs on your platform.         &lt;/li&gt;
&lt;li&gt;           Choose a distribution to install.         &lt;/li&gt;
&lt;li&gt;           Download the distribution and verify its integrity.         &lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;This section contains the information necessary to carry out these       steps. After doing so, you can use the instructions in later       sections.&lt;br /&gt;
&lt;br /&gt;
[ &lt;a href=&quot;http://mysql-tutorial.blogspot.com/2011/03/operating-systems-supported-by-mysql.html&quot;&gt;next &lt;/a&gt;]</content><link rel='replies' type='application/atom+xml' href='http://mysql-tutorial.blogspot.com/feeds/9198090468802971371/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/installing-and-upgrading-mysql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/9198090468802971371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/316532415128145912/posts/default/9198090468802971371'/><link rel='alternate' type='text/html' href='http://mysql-tutorial.blogspot.com/2011/03/installing-and-upgrading-mysql.html' title='Installing and Upgrading MySQL'/><author><name>myesqiuel</name><uri>http://www.blogger.com/profile/09622794715482170718</uri><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>