{"id":5790,"date":"2021-04-02T12:30:57","date_gmt":"2021-04-02T12:30:57","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=5790"},"modified":"2021-04-02T12:30:57","modified_gmt":"2021-04-02T12:30:57","slug":"mysql-queries","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/","title":{"rendered":"MySql queries:"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Inserting data into a existing table:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax without column names specified:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO table_name VALUES ('value1','value2');<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/Joydeep-cotocus\/e7cfffffea5ffab8fde1dc9144ea6dbc.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\">In the example we have inserted the data in a customer_table where we have 4 columns with name cust_id, first_name, last_name, age and we have inserted the data in the columns with this command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax without column names specified:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSERT INTO table_name ('column1','column2') VALUES ('value1','value2');<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/Joydeep-cotocus\/2fad1e79c63ad00da25c866ea8bf0ec7.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\">In this example we have inserted the data in three columns excluding the last_name column, by doing this it will store the information in all the columns and will show NULL in the last_name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Inserting data in multiple rows:<\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/Joydeep-cotocus\/6f6678e2ac3440fe59b546a0dcddb297.js\"><\/script>\n\n\n\n<ul class=\"wp-block-list\"><li>To &#8216;SELECT&#8217; a statement in a table:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>Select column_name from table_name;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Following command will show the data stored in the column_name column in the database.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>To use &#8216;WHERE&#8217; command in a table:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>Select column_name from table_name Where (column_name = condition);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We have a table with Customers name , age and email given and we need to see only the data of customer whose age is greater than 25.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Select * from customer_table where age>25;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command will show the data of the customers whose age is greater than 25.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>To use logical operators in the query:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>Select column_name from table_name Where (column_name = condition) AND (column_name = condition) OR (column_name = condition);<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>To update data in the table:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE table_name SET column_name='abc' WHERE condition(column);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For example to update the last name of a customer:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>UPDATE customer_table SET Last_name='John' WHERE cust_id=5<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inserting data into a existing table: Syntax without column names specified: Example: In the example we have inserted the data [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[72],"tags":[5157,5187,493,5186],"class_list":["post-5790","post","type-post","status-publish","format-standard","hentry","category-database","tag-database","tag-insert","tag-mysql","tag-queries"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySql queries: - scmGalaxy<\/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:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySql queries: - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Inserting data into a existing table: Syntax without column names specified: Example: In the example we have inserted the data [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-02T12:30:57+00:00\" \/>\n<meta name=\"author\" content=\"Joydeep M\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joydeep M\" \/>\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:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/mysql-queries\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/mysql-queries\\\/\"},\"author\":{\"name\":\"Joydeep M\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/8a2c0533775223a96dd307662111bac6\"},\"headline\":\"MySql queries:\",\"datePublished\":\"2021-04-02T12:30:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/mysql-queries\\\/\"},\"wordCount\":192,\"commentCount\":0,\"keywords\":[\"database\",\"insert\",\"mysql\",\"queries\"],\"articleSection\":[\"Database\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/mysql-queries\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/mysql-queries\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/mysql-queries\\\/\",\"name\":\"MySql queries: - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2021-04-02T12:30:57+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/8a2c0533775223a96dd307662111bac6\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/mysql-queries\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/mysql-queries\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/mysql-queries\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySql queries:\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/8a2c0533775223a96dd307662111bac6\",\"name\":\"Joydeep M\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g\",\"caption\":\"Joydeep M\"},\"description\":\"An investment in knowledge pays the best interest.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/joydeep-kumar-538412208\\\/\"],\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/joydeep\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySql queries: - scmGalaxy","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:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/","og_locale":"en_US","og_type":"article","og_title":"MySql queries: - scmGalaxy","og_description":"Inserting data into a existing table: Syntax without column names specified: Example: In the example we have inserted the data [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/","og_site_name":"scmGalaxy","article_published_time":"2021-04-02T12:30:57+00:00","author":"Joydeep M","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Joydeep M","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/"},"author":{"name":"Joydeep M","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/8a2c0533775223a96dd307662111bac6"},"headline":"MySql queries:","datePublished":"2021-04-02T12:30:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/"},"wordCount":192,"commentCount":0,"keywords":["database","insert","mysql","queries"],"articleSection":["Database"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/","name":"MySql queries: - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2021-04-02T12:30:57+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/8a2c0533775223a96dd307662111bac6"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/mysql-queries\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"MySql queries:"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/8a2c0533775223a96dd307662111bac6","name":"Joydeep M","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fb490db5d492c960456cc628f9e832fda72c5bc426cd8a13b18cbb95bca7ce99?s=96&d=mm&r=g","caption":"Joydeep M"},"description":"An investment in knowledge pays the best interest.","sameAs":["https:\/\/www.linkedin.com\/in\/joydeep-kumar-538412208\/"],"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/joydeep\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=5790"}],"version-history":[{"count":3,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5790\/revisions"}],"predecessor-version":[{"id":5793,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5790\/revisions\/5793"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=5790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=5790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=5790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}