{"id":222,"date":"2017-12-10T08:56:52","date_gmt":"2017-12-10T08:56:52","guid":{"rendered":"https:\/\/blinksql.com\/?p=222"},"modified":"2017-12-10T08:56:52","modified_gmt":"2017-12-10T08:56:52","slug":"basic-commands-in-mysql","status":"publish","type":"post","link":"https:\/\/blinksql.com\/?p=222","title":{"rendered":"Basic Commands in Mysql"},"content":{"rendered":"<p>-&gt;\u00a0This is the world&#8217;s second most popular and widely used open source database.<\/p>\n<p>-&gt; All the database names, table names and table fields name are case sensitive.<\/p>\n<p>-&gt; To switch from one database to another database<\/p>\n<p><strong>cmd:USE\u00a0database_name;\u00a0\u00a0<\/strong><\/p>\n<p>-&gt; To list all the databases<\/p>\n<p><strong>cmd: show databases;<\/strong><\/p>\n<p>-&gt; To see the tables<\/p>\n<p><strong>cmd: show tables;<\/strong><\/p>\n<p>-&gt; To select the first record<\/p>\n<p><strong><span class=\"keyword\">cmd:SELECT<\/span>\u00a0column_name\u00a0\u00a0<span class=\"keyword\">FROM<\/span>\u00a0table_name LIMIT\u00a01;\u00a0\u00a0<\/strong><\/p>\n<p><strong>Mysql_connect:<\/strong><\/p>\n<p>Every time you need to open and close database connection, depending on the request.<\/p>\n<p><strong>Mysql_pconnect:<\/strong><\/p>\n<p>It opens a persistent connection to the database that can not be closed.<\/p>\n<p class=\"h3\">\u00a0i_am_a_dummy flag:<\/p>\n<p>It enables MySQL engine to refuse any UPDATE or DELETE statement to execute if the WHERE clause is not present.<\/p>\n<p><strong>To find Nth highest salary is:<\/strong><\/p>\n<p><strong>\u00a0cmd:<span class=\"keyword\">select<\/span>\u00a0<span class=\"keyword\">distinct<\/span>(salary)\u00a0<span class=\"keyword\">from<\/span>\u00a0employee\u00a0<span class=\"keyword\">order<\/span>\u00a0<span class=\"keyword\">by<\/span>\u00a0salary\u00a0<span class=\"keyword\">desc<\/span>\u00a0limit\u00a0n-1,1\u00a0\u00a0<\/strong><\/p>\n<div><strong>Default Port of Mysql:<\/strong><\/div>\n<div>The default port of MySQL Server is 3306.<\/div>\n<div><\/div>\n<div>\n<p class=\"h3\">To retrieve a hundred books starting from 20th:<\/p>\n<p>SELECT book_title FROM books LIMIT 20, 100;<\/p>\n<\/div>\n<div><\/div>\n<div><strong>DataDirectory:<\/strong><\/div>\n<div>The default location of MySQL data directory in windows is C:\\mysql\\data or C:\\Program Files\\MySQL\\MySQL Server 5.0 \\data.<\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>-&gt;\u00a0This is the world&#8217;s second most popular and widely used open source database. -&gt; All the database names, table names and table fields name are case sensitive. -&gt; To switch&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":""},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.10 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Basic Commands in Mysql - Blink SQL<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blinksql.com\/?p=222\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Basic Commands in Mysql - Blink SQL\" \/>\n<meta property=\"og:description\" content=\"-&gt;\u00a0This is the world&#8217;s second most popular and widely used open source database. -&gt; All the database names, table names and table fields name are case sensitive. -&gt; To switch&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blinksql.com\/?p=222\" \/>\n<meta property=\"og:site_name\" content=\"Blink SQL\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-10T08:56:52+00:00\" \/>\n<meta name=\"author\" content=\"Hannie\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@harika_sanaka\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hannie\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blinksql.com\/?p=222#article\",\"isPartOf\":{\"@id\":\"https:\/\/blinksql.com\/?p=222\"},\"author\":{\"name\":\"Hannie\",\"@id\":\"https:\/\/blinksql.com\/#\/schema\/person\/f04b99304f59e14956e768e764d2afd4\"},\"headline\":\"Basic Commands in Mysql\",\"datePublished\":\"2017-12-10T08:56:52+00:00\",\"dateModified\":\"2017-12-10T08:56:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blinksql.com\/?p=222\"},\"wordCount\":204,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/blinksql.com\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blinksql.com\/?p=222#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blinksql.com\/?p=222\",\"url\":\"https:\/\/blinksql.com\/?p=222\",\"name\":\"Basic Commands in Mysql - Blink SQL\",\"isPartOf\":{\"@id\":\"https:\/\/blinksql.com\/#website\"},\"datePublished\":\"2017-12-10T08:56:52+00:00\",\"dateModified\":\"2017-12-10T08:56:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/blinksql.com\/?p=222#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blinksql.com\/?p=222\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blinksql.com\/?p=222#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blinksql.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Basic Commands in Mysql\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blinksql.com\/#website\",\"url\":\"https:\/\/blinksql.com\/\",\"name\":\"Blink SQL\",\"description\":\" Thinking SQL\",\"publisher\":{\"@id\":\"https:\/\/blinksql.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blinksql.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/blinksql.com\/#organization\",\"name\":\"Blink SQL\",\"url\":\"https:\/\/blinksql.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blinksql.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blinksql.com\/wp-content\/uploads\/2022\/11\/cropped-BlinkSQL-removebg.png\",\"contentUrl\":\"https:\/\/blinksql.com\/wp-content\/uploads\/2022\/11\/cropped-BlinkSQL-removebg.png\",\"width\":280,\"height\":172,\"caption\":\"Blink SQL\"},\"image\":{\"@id\":\"https:\/\/blinksql.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/blinksql.com\/#\/schema\/person\/f04b99304f59e14956e768e764d2afd4\",\"name\":\"Hannie\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blinksql.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c5876b3497d2c2eb98256b7c183220c1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c5876b3497d2c2eb98256b7c183220c1?s=96&d=mm&r=g\",\"caption\":\"Hannie\"},\"sameAs\":[\"http:\/\/blinksql.com\",\"https:\/\/twitter.com\/harika_sanaka\"],\"url\":\"https:\/\/blinksql.com\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Basic Commands in Mysql - Blink SQL","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blinksql.com\/?p=222","og_locale":"en_US","og_type":"article","og_title":"Basic Commands in Mysql - Blink SQL","og_description":"-&gt;\u00a0This is the world&#8217;s second most popular and widely used open source database. -&gt; All the database names, table names and table fields name are case sensitive. -&gt; To switch&hellip;","og_url":"https:\/\/blinksql.com\/?p=222","og_site_name":"Blink SQL","article_published_time":"2017-12-10T08:56:52+00:00","author":"Hannie","twitter_card":"summary_large_image","twitter_creator":"@harika_sanaka","twitter_misc":{"Written by":"Hannie","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blinksql.com\/?p=222#article","isPartOf":{"@id":"https:\/\/blinksql.com\/?p=222"},"author":{"name":"Hannie","@id":"https:\/\/blinksql.com\/#\/schema\/person\/f04b99304f59e14956e768e764d2afd4"},"headline":"Basic Commands in Mysql","datePublished":"2017-12-10T08:56:52+00:00","dateModified":"2017-12-10T08:56:52+00:00","mainEntityOfPage":{"@id":"https:\/\/blinksql.com\/?p=222"},"wordCount":204,"commentCount":0,"publisher":{"@id":"https:\/\/blinksql.com\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blinksql.com\/?p=222#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blinksql.com\/?p=222","url":"https:\/\/blinksql.com\/?p=222","name":"Basic Commands in Mysql - Blink SQL","isPartOf":{"@id":"https:\/\/blinksql.com\/#website"},"datePublished":"2017-12-10T08:56:52+00:00","dateModified":"2017-12-10T08:56:52+00:00","breadcrumb":{"@id":"https:\/\/blinksql.com\/?p=222#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blinksql.com\/?p=222"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blinksql.com\/?p=222#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blinksql.com\/"},{"@type":"ListItem","position":2,"name":"Basic Commands in Mysql"}]},{"@type":"WebSite","@id":"https:\/\/blinksql.com\/#website","url":"https:\/\/blinksql.com\/","name":"Blink SQL","description":" Thinking SQL","publisher":{"@id":"https:\/\/blinksql.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blinksql.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/blinksql.com\/#organization","name":"Blink SQL","url":"https:\/\/blinksql.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blinksql.com\/#\/schema\/logo\/image\/","url":"https:\/\/blinksql.com\/wp-content\/uploads\/2022\/11\/cropped-BlinkSQL-removebg.png","contentUrl":"https:\/\/blinksql.com\/wp-content\/uploads\/2022\/11\/cropped-BlinkSQL-removebg.png","width":280,"height":172,"caption":"Blink SQL"},"image":{"@id":"https:\/\/blinksql.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/blinksql.com\/#\/schema\/person\/f04b99304f59e14956e768e764d2afd4","name":"Hannie","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blinksql.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c5876b3497d2c2eb98256b7c183220c1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c5876b3497d2c2eb98256b7c183220c1?s=96&d=mm&r=g","caption":"Hannie"},"sameAs":["http:\/\/blinksql.com","https:\/\/twitter.com\/harika_sanaka"],"url":"https:\/\/blinksql.com\/?author=2"}]}},"_links":{"self":[{"href":"https:\/\/blinksql.com\/index.php?rest_route=\/wp\/v2\/posts\/222"}],"collection":[{"href":"https:\/\/blinksql.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blinksql.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blinksql.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blinksql.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=222"}],"version-history":[{"count":0,"href":"https:\/\/blinksql.com\/index.php?rest_route=\/wp\/v2\/posts\/222\/revisions"}],"wp:attachment":[{"href":"https:\/\/blinksql.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blinksql.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blinksql.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}