{"id":686,"date":"2012-07-13T10:29:27","date_gmt":"2012-07-13T02:29:27","guid":{"rendered":"http:\/\/rmohan.com\/?p=686"},"modified":"2012-07-13T11:09:16","modified_gmt":"2012-07-13T03:09:16","slug":"learn-mysql","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=686","title":{"rendered":"Learn MySQL"},"content":{"rendered":"<h3>Learn MySQL<\/h3>\n<h2>How To Connect MySQL Database Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Client tools then copy &amp; paste the below code to Connect to MySQL database server<\/p>\n<pre>   -- mysql.exe location: c:\\xampp\\mysql\\bin\\mysql.exe\r\n   -- host: localhost\r\n   -- username: root\r\n   -- password: ***\r\n\r\n   -- modify your host location, username, password accordingly.\r\n   -- i am using dos prompt as client. you can use phpmyadmin or anything else you like.\r\n\r\n   -- just copy &amp; paste the bellow code in ms-dos prompt<\/pre>\n<\/div>\n<div>\n<pre>   c:\\xampp\\mysql\\bin\\mysql -hlocalhost -uroot -p<\/pre>\n<\/div>\n<div>\n<pre>      -- that's it!! we are connected to mysql database using the mentioned credentials\r\n      -- is comment in MySQL\r\n      -- in fact it is comment in MSSQL and Oracle as well<\/pre>\n<h2>How To Create Database In MySQL Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to create a database in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>   -- How To Create Database In MySQL Tutorial Example\r\n\r\n   CREATE DATABASE basic;\r\n\r\n   -- that's it!! mysql database \"basic\" has been created<\/pre>\n<\/div>\n<div>\n<pre>      -- is comment in MySQL\r\n      -- in fact it is comment in MSSQL and Oracle as well<\/pre>\n<h2>How To Create Table In MySQL Database Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to create a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>   -- How To Create Table In MySQL Database Tutorial Example\r\n\r\n   CREATE TABLE test\r\n   (\r\n     TestID int(11) default NULL,\r\n     TestName varchar(100) default NULL,\r\n     TestAge int(11) default NULL\r\n   );\r\n\r\n   -- that's it!! mysql database table \"test\" has been created with 3 columns<\/pre>\n<\/div>\n<div>\n<h2>How To Insert Single Row In MySQL Table Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to Insert into a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>   -- How To Insert Single Row In MySQL Table Tutorial Example\r\n\r\n   INSERT INTO  test(TestID ,TestName,TestAge) VALUES (1 , 'Donald', 33);\r\n\r\n   -- that's it!! a row has been inserted in mysql database table \"test\" with 3 columns value<\/pre>\n<\/div>\n<div>\n<pre>      -- is comment in MySQL\r\n      -- in fact it is comment in MSSQL and Oracle as well<\/pre>\n<h2>How To Insert Rows In MySQL Table Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to Insert multiple rows into a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<pre>-- How To Insert Rows In MySQL Table Tutorial Example\r\n\r\nINSERT INTO  test(TestID ,TestName,TestAge) VALUES\r\n(2 , 'Douglas', 34),\r\n(3 , 'Jennifer', 35),\r\n(4 , 'Michael', 49),\r\n(5 , 'Pat', 40),\r\n(6 , 'Susan', 55),\r\n(7 , 'Hermann', 53),\r\n(8 , 'Shelley', 29),\r\n(9 , 'William', 21),\r\n(10, 'Alexander', 42);\r\n\r\n-- that's it!!<\/pre>\n<h2>How To Insert Specific Columns In MySQL Tutorial Example<\/h2>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to Insert specific columns into a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<pre>-- How To Insert Specific Columns In MySQL Tutorial Example\r\n\r\nINSERT INTO  test(TestName,TestAge) VALUES ('Noor.Hasan', 28);\r\n\r\n-- that's it!!<\/pre>\n<\/div>\n<pre><\/pre>\n<h3>Select Data From MySQL Table Tutorial Example<\/h3>\n<div><\/div>\n<h2>How To Select Data From MySQL Table Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to select or retrive data from a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<pre>-- How To Select Data From MySQL Table Tutorial Example\r\n\r\nSELECT * FROM  test;\r\n\r\n-- that's it!!\r\n\r\n<\/pre>\n<h2>How To Select Specific Rows From MySQL Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to select or retrive specific rows data from a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>-- How To Select Specific Rows From MySQL Tutorial Example\r\n\r\nSELECT TestName, TestAge FROM  test WHERE TestID=10;\r\n\r\n-- that's it!! TestName, TestAge columns of id=10 of mysql database table \"test\" has been selected<\/pre>\n<\/div>\n<div>\n<h2>How To Select Data Using Like From MySQL Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to select or retrive rows data using LIKE from a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>-- How To Select Data Using Like From MySQL Tutorial Example\r\n\r\nSELECT * FROM test WHERE TestName LIKE '%Do%';\r\n\r\n-- that's it!! all rows and all columns of mysql database table \"test\"\r\n-- whose Name has the string \"Do\" have been selected<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h2>How To Ascending Sort\/Order MySQL Data Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to select or retrive data ascendingly sort or order from a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>-- How To Ascending Sort\/Order MySQL Data Tutorial Example\r\n\r\nSELECT * FROM test ORDER BY TestName ASC;\r\n\r\n-- that's it!! all rows &amp; columns of mysql database table \"test\" have been selected\r\n-- Sort or Order By TestName Ascendingly\r\n\r\n<\/pre>\n<h2>How To Descending Sort\/Order MySQL Data Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to select or retrive data descendingly sort or order from a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>-- How To Descending Sort\/Order MySQL Data Tutorial Example\r\n\r\nSELECT * FROM test ORDER BY TestName DESC;\r\n\r\n-- that's it!! all rows &amp; columns of mysql database table \"test\" have been selected\r\n-- Sort or Order By TestName Descendingly\r\n\r\n\r\n<\/pre>\n<h2>How To Update Data In MySQL Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to update from a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<pre>-- How To Update Data In MySQL Tutorial Example\r\n\r\nUPDATE test SET TestAge=99;\r\n\r\n-- that's it!!\r\n\r\n<\/pre>\n<h2>How To Update Specific Rows In MySQL Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to update specific rows from a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>-- How To Update Specific Rows In MySQL Tutorial Example\r\n\r\nUPDATE test SET TestID=11 WHERE TestName='Noor.Hasan';\r\n\r\n-- that's it!! TestID column of all rows of mysql database table \"test\" have\/has been updated\r\n-- whose TestName value is \"Noor.Hasan\"<\/pre>\n<h2>How To Delete Specific Rows Data From MySQL Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to delete specific rows from a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>-- How To Delete Specific Rows Data From MySQL Tutorial Example\r\n\r\nDELETE FROM test WHERE TestName='Noor.Hasan';\r\n\r\n-- that's it!! all rows of mysql database table \"test\" have\/has been deleted\r\n-- whose TestName value is \"Noor.Hasan\"<\/pre>\n<h2>How To Delete Data From MySQL Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to delete data from a database table &#8220;test&#8221; in MySQL Database Server<\/p>\n<\/div>\n<pre>-- How To Delete Data From MySQL Tutorial Example\r\n\r\nDELETE FROM test;\r\n\r\n-- that's it!! all rows of mysql database table \"test\" have\/has been deleted\r\n-- because there is no WHERE condition, so be careful before using it in Production one \r\n\r\n\r\n<\/pre>\n<h2>MySQL TRUNCATE TABLE Example<\/h2>\n<div>\n<p>Open your SQL Query Editor then copy &amp; paste the below code to TRUNCATE a table in MySQL:<\/p>\n<\/div>\n<div>\n<pre>   TRUNCATE TABLE test<\/pre>\n<\/div>\n<h4>MySQL TRUNCATE TABLE Example &#8211; Execution in SQL Query Editor<\/h4>\n<h2>How To Drop Table From MySQL Database Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to drop table &#8220;test&#8221; from a database in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>-- How To Drop Table From MySQL Database Tutorial Example\r\n\r\nDROP TABLE test;\r\n\r\n-- that's it!! mysql database table \"test\" has been droped\r\n\r\n\r\n<\/pre>\n<h2>How To Drop Database In MySQL Tutorial Example<\/h2>\n<div>\n<p>Open your MySQL Query Editor then copy &amp; paste the below code to drop a database in MySQL Database Server<\/p>\n<\/div>\n<div>\n<pre>-- How To Drop Database In MySQL Tutorial Example\r\n\r\nDROP Database basic;\r\n\r\n-- that's it!! mysql database \"basic\" has been droped forever\r\n\r\n\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<pre><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn MySQL How To Connect MySQL Database Tutorial Example <\/p>\n<p>Open your MySQL Client tools then copy &amp; paste the below code to Connect to MySQL database server<\/p>\n<p> &#8212; mysql.exe location: c:\\xampp\\mysql\\bin\\mysql.exe &#8212; host: localhost &#8212; username: root &#8212; password: *** &#8212; modify your host location, username, password accordingly. &#8212; i am using dos prompt as [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/686"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=686"}],"version-history":[{"count":3,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/686\/revisions"}],"predecessor-version":[{"id":694,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/686\/revisions\/694"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}