{"id":96939,"date":"2020-11-09T11:00:00","date_gmt":"2020-11-09T09:00:00","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=96939"},"modified":"2020-11-04T14:35:12","modified_gmt":"2020-11-04T12:35:12","slug":"sql-select-statement-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/","title":{"rendered":"SQL SELECT Statement Example"},"content":{"rendered":"<h2 class=\"wp-block-heading\" id=\"h-1-introduction\">1. Introduction<\/h2>\n<p>In this article, we will look at one of the most used clauses used in SQL known as SELECT.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-1-1-what-is-sql\">1.1 What is SQL?<\/h3>\n<p>In 1974, Donald Chamberlin and Robert Boyce designed a programming language called SQL or &#8220;sequel&#8221;. It is based on relational algebra and tuple-relational calculus. So, this is the programming language for designing and maintaining a Relational database management system (RDBMS). Depending upon the RDBMS used, the SQL can have dialects. For example, Oracle uses PL\/SQL and MS SQL Server uses T-SQL and MySQL uses SQL.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-1-2-setup\">1.2 Setup<\/h3>\n<p>This is the setup for running queries &#8211;<\/p>\n<ul class=\"wp-block-list\">\n<li>MySQL Community Server version 8.0.22. To install, please visit the <a rel=\"noreferrer noopener\" href=\"https:\/\/dev.mysql.com\/downloads\/windows\/installer\/8.0.html\" target=\"_blank\">MySQL Community Downloads<\/a> page. Its <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/\" target=\"_blank\" rel=\"noreferrer noopener\">documentation<\/a> is available here.<\/li>\n<li>For running queries, we use the <a href=\"https:\/\/dev.mysql.com\/doc\/workbench\/en\/\" target=\"_blank\" rel=\"noreferrer noopener\">MySQL 8.0 Workbench<\/a> which is both a part of the community package and a separate download.<\/li>\n<li>SAKILA Database is provided by MySQL itself. The <a href=\"https:\/\/dev.mysql.com\/doc\/sakila\/en\/\" target=\"_blank\" rel=\"noreferrer noopener\">documentation<\/a> provides details about the structure, installation steps(if any), Schema details, etc.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-2-sql-select-clause\">2. SQL SELECT Clause<\/h2>\n<p>In this article, we are going to look at one of the most used clauses known as the SELECT Clause which extracts data from a database.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-2-1-select-in-relational-algebra\">2.1 Select in Relational Algebra<\/h3>\n<p>As per Relational Algebra, the select operator selects a subset of tuples(rows) according to the given condition. The symbol to denote Select is <code> \u03c3<sub>p<\/sub>(r)<\/code><\/p>\n<p>where,<\/p>\n<p>\n<code>\u03c3<\/code> = predicate <br \/>\n<code>p<\/code> = prepositional logic i.e. conditions put on it<br \/>\n<code>r<\/code> = relation i.e table_name<\/p>\n<p>example<\/p>\n<p><code>\u03c3 <sub>amount<\/sub> &lt; 2.99(Payment) <\/code><\/p>\n<p>this will return all the records from the Payment table where amount &gt; 2.99 <\/p>\n<h3 class=\"wp-block-heading\" id=\"h-2-2-select-clause\">2.2 SELECT CLAUSE<\/h3>\n<ul class=\"wp-block-list\">\n<li>The Select clause makes up an integral part of queries in the database. Like in Relational Algebra the select statement retrieves one or more records from one or more tables. The result set is tuples(rows).<\/li>\n<li>Select clauses are a part of the Data Manipulation Language (DML) commands.<\/li>\n<li>It is one of the most complex statements in SQL which has many optional clauses attached to it.<\/li>\n<li>The clauses are as follows:\n<ul style=\"list-style-type: lower-alpha\">\n<li>FROM: The FROM Clause retrieves data from the Tables mentioned. We also use an optional JOIN clause.<\/li>\n<li>Where: Where Clause is the conditions or restrictions put on the records. The conditions are the \u201cpredicate\u201d.<\/li>\n<li>GROUP BY: Group by clause is to club rows having similar values into smaller groups.<\/li>\n<li>Having: The Having clause filters rows from the Group by and aggregate functions.<\/li>\n<li>Order by: This clause sorts the result set based on some column. By default, Order by sorts columns in the Ascending order.<\/li>\n<li>Distinct: The Distinct keyword eliminates duplicate rows or tuples.<\/li>\n<li>The asterisk (*) is a special column name we use to get all the columns from the table or tables used in the from clause.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Because it is just retrieval of records, the select statement does not alter the database. Besides this, the \u201cSELECT INTO\u201d  clause modifies variables, files, and sometimes tables. More details are available on the <a rel=\"noreferrer noopener\" href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/select-into.html\" target=\"_blank\">SELECT INTO Documentation<\/a>.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>As per MySQL Documentation the syntax of the Select clause with all its optional clauses is<\/p>\n<pre class=\"brush:sql\">SELECT\n    [ALL | DISTINCT | DISTINCTROW ]\n    [HIGH_PRIORITY]\n    [STRAIGHT_JOIN]\n    [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]\n    [SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]\n    select_expr [, select_expr] ...\n    [into_option]\n    [FROM table_references\n      [PARTITION partition_list]]\n    [WHERE where_condition]\n    [GROUP BY {col_name | expr | position}, ... [WITH ROLLUP]]\n    [HAVING where_condition]\n    [WINDOW window_name AS (window_spec)\n        [, window_name AS (window_spec)] ...]\n    [ORDER BY {col_name | expr | position}\n      [ASC | DESC], ... [WITH ROLLUP]]\n    [LIMIT {[offset,] row_count | row_count OFFSET offset}]\n    [into_option]\n    [FOR {UPDATE | SHARE}\n        [OF tbl_name [, tbl_name] ...]\n        [NOWAIT | SKIP LOCKED]\n      | LOCK IN SHARE MODE]\n    [into_option]\n\ninto_option: {\n    INTO OUTFILE 'file_name'\n        [CHARACTER SET charset_name]\n        export_options\n  | INTO DUMPFILE 'file_name'\n  | INTO var_name [, var_name] ...\n}\n<\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-2-1-simplest-sql-syntax\">2.1 Simplest SQL Syntax<\/h3>\n<p>The simplest Select syntax is just a select query without even the from clause.<\/p>\n<pre class=\"brush:sql\"> Select 1 + 2;<\/pre>\n<p>which is equivalent to<\/p>\n<pre class=\"brush:sql\"> SELECT 1+ 2 FROM DUAL;<\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-3-examples\">3. Examples<\/h2>\n<p>Next, we will look at different examples. We will look at some clauses used with Select.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-3-1-select-with-from-clause\">3.1 SELECT with FROM Clause<\/h3>\n<p>To get all records, we use *. But if the table is big (like the one in the example which has 16,000+ records), it is advisable to use a LIMIT clause.<\/p>\n<p>Query<\/p>\n<pre class=\"brush:sql\">SELECT * \nFROM RENTAL \nLIMIT 10;<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"820\" height=\"521\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_all.jpg\" alt=\"SQL SELECT - Select all columns from a table\" class=\"wp-image-96941\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_all.jpg 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_all-300x191.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_all-768x488.jpg 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><figcaption>Select all columns from table<\/figcaption><\/figure>\n<\/div>\n<p>We can select specific column names from a table as well.<\/p>\n<p>Query<\/p>\n<pre class=\"brush:sql\">SELECT INVENTORY_ID, CUSTOMER_ID, RETURN_DATE\nFROM RENTAL\nLIMIT 12;\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"646\" height=\"474\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_column_names.jpg\" alt=\"SQL SELECT - select specific column names from table\" class=\"wp-image-96942\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_column_names.jpg 646w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_column_names-300x220.jpg 300w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><figcaption>Select specific columns<\/figcaption><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\" id=\"h-3-2-select-with-from-and-where-clause\">3.2 Select with FROM and WHERE CLAUSE<\/h3>\n<p>Select Clause can have a where clause and can also form subqueries or joins. The Where clause filters records based on predicates i.e. conditions.<\/p>\n<p>Where with a predicate<\/p>\n<pre class=\"brush:sql\">SELECT INVENTORY_ID,CUSTOMER_ID,RETURN_DATE\nFROM RENTAL\nWHERE CUSTOMER_ID =459;\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"591\" height=\"693\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_where.png\" alt=\"SQL SELECT - Select with Where clause\" class=\"wp-image-96943\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_where.png 591w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_where-256x300.png 256w\" sizes=\"(max-width: 591px) 100vw, 591px\" \/><figcaption>Select with Where clause<\/figcaption><\/figure>\n<\/div>\n<p>Query for where with a subquery:<\/p>\n<pre class=\"brush:sql\">SELECT *\nFROM PAYMENT\nWHERE AMOUNT &gt;=2.99 \nAND CUSTOMER_ID = 1\nAND RENTAL_ID IN (SELECT RENTAL_ID from RENTAL);\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"810\" height=\"732\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_subquery.jpg\" alt=\"SQL SELECT - subquery\" class=\"wp-image-96944\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_subquery.jpg 810w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_subquery-300x271.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_subquery-768x694.jpg 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><figcaption>Subquery<\/figcaption><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\" id=\"h-3-3-select-with-aggregate-functions-and-group-by-function\">3.3 SELECT WITH Aggregate functions and group by function<\/h3>\n<p>We can Select queries with Aggregate functions like AVG, MAX, COUNT. Along with the Aggregate functions we use Having clause because it filters the result set returned by aggregate functions.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-3-3-1-aggregate-function-query\">3.3.1 Aggregate function Query<\/h4>\n<pre class=\"brush:sql\">SELECT AVG(AMOUNT),CUSTOMER_ID\nFROM PAYMENT\nGROUP BY CUSTOMER_ID;\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"529\" height=\"671\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_aggregate.jpg\" alt=\"SQL SELECT - Select with aggregate functions\" class=\"wp-image-96945\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_aggregate.jpg 529w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_aggregate-237x300.jpg 237w\" sizes=\"(max-width: 529px) 100vw, 529px\" \/><figcaption>Select with aggregate functions<\/figcaption><\/figure>\n<\/div>\n<h4 class=\"wp-block-heading\" id=\"h-3-3-2-having-clause-query\">3.3.2 Having Clause Query:<\/h4>\n<p>The having clause is used to filter the aggregate function result set.<\/p>\n<pre class=\"brush:sql\">SELECT C.CUSTOMER_ID,C.FIRST_NAME,C.LAST_NAME\nFROM PAYMENT P,CUSTOMER C\nWHERE P.CUSTOMER_ID = C.CUSTOMER_ID\nGROUP BY C.CUSTOMER_ID\nHAVING AVG(P.AMOUNT) &gt; 3\nLIMIT 20;\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"682\" height=\"725\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_having.jpg\" alt=\"SQL SELECT - Select with a Having clause\" class=\"wp-image-96946\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_having.jpg 682w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_having-282x300.jpg 282w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><figcaption>Select with a Having clause<\/figcaption><\/figure>\n<\/div>\n<h4 class=\"wp-block-heading\" id=\"h-3-3-3-select-in-having-clause-query\">3.3.3 Select in Having Clause Query<\/h4>\n<p>Having clause can have select to form a subquery<\/p>\n<pre class=\"brush:sql\">SELECT P.CUSTOMER_ID,FIRST_NAME,LAST_NAME,EMAIL\nFROM PAYMENT P,CUSTOMER C\nWHERE P.CUSTOMER_ID=P.CUSTOMER_ID\nGROUP BY C.CUSTOMER_ID\nHAVING MAX(P.AMOUNT) &gt; (SELECT AVG(AMOUNT) FROM PAYMENT)\nLIMIT 20;\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"611\" height=\"731\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_inHaving.jpg\" alt=\"Having with subquery\" class=\"wp-image-96951\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_inHaving.jpg 611w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_inHaving-251x300.jpg 251w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><figcaption>Having with subquery<\/figcaption><\/figure>\n<\/div>\n<h4 class=\"wp-block-heading\" id=\"h-3-3-4-query-for\">3.3.4 Query for <\/h4>\n<p>The SQL Select statement is used extensively when creating Joins on tables. More on Joins <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/join.html\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n<p>The following query gives back the business done by the 2 DVD-rental stores<\/p>\n<pre class=\"brush:sql\">SELECT S1.STORE_ID, S2.SALES \nFROM STORE S1\nJOIN (\n\tSELECT CUS.STORE_ID, SUM(PAY.AMOUNT) SALES\n\tFROM CUSTOMER CUS\n\tJOIN PAYMENT PAY\n\tON PAY.CUSTOMER_ID = CUS.CUSTOMER_ID\n    GROUP BY CUS.STORE_ID\n  ) S2\nON S1.STORE_ID = S2.STORE_ID\nORDER BY S1.STORE_ID;\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"575\" height=\"436\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_JOIN.jpg\" alt=\"join clause\" class=\"wp-image-96952\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_JOIN.jpg 575w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_JOIN-300x227.jpg 300w\" sizes=\"(max-width: 575px) 100vw, 575px\" \/><figcaption>Join Clause<\/figcaption><\/figure>\n<\/div>\n<h4 class=\"wp-block-heading\" id=\"h-3-3-5-select-with-in-built-functions\">3.3.5 Select with In-Built Functions<\/h4>\n<p>In-built functions like ROW_NUMBER or RANK can be used with Select. Below Query Shows an example of a ROW_NUMBER function in MySQL<\/p>\n<pre class=\"brush:sql\">select ROW_NUMBER() OVER (ORDER BY AMOUNT DESC) CUSTOMER_ID, AMOUNT\nFROM PAYMENT\nLIMIT 10;\n\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"710\" height=\"563\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_row_number.jpg\" alt=\"row number function\" class=\"wp-image-96953\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_row_number.jpg 710w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_row_number-300x238.jpg 300w\" sizes=\"(max-width: 710px) 100vw, 710px\" \/><figcaption>row number function<\/figcaption><\/figure>\n<\/div>\n<h4 class=\"wp-block-heading\" id=\"h-3-3-6-select-in-views\">3.3.6 Select in Views<\/h4>\n<p>Views or Inline Views use select statements as well and below given Query is one such View related to Documentary Films<\/p>\n<p>Query for View creation<\/p>\n<pre class=\"brush:sql\">CREATE VIEW DOCUMENTARY_FILM_LIST AS \nSELECT F.TITLE,F.DESCRIPTION,F.LENGTH,F.RATING,GROUP_CONCAT(CONCAT(A.FIRST_NAME,A.LAST_NAME) SEPARATOR ', ') AS `ACTORS`\nFROM FILM_ACTOR FA, FILM F ,ACTOR A\nWHERE F.FILM_ID = FA.FILM_ID \nAND A.ACTOR_ID = FA.ACTOR_ID\nAND F.FILM_ID IN (\nSELECT FILM_ID FROM FILM_CATEGORY, CATEGORY\nWHERE CATEGORY.CATEGORY_ID = FILM_CATEGORY.CATEGORY_ID\nAND CATEGORY.CATEGORY_ID = 6)\nGROUP BY F.FILM_ID;\n\n<\/pre>\n<p>Query to get Output:<\/p>\n<pre class=\"brush:sql\">SELECT * FROM DOCUMENTARY_FILM_LIST;<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"810\" height=\"474\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_view.jpg\" alt=\"View Query.\" class=\"wp-image-96954\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_view.jpg 810w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_view-300x176.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/select_view-768x449.jpg 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><figcaption>View Query<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\" id=\"h-4-summary\">4. Summary<\/h2>\n<p>In this article, we saw one of the most used statements in SQL i.e. the SELECT Clause. We saw a lot of examples with various clauses that are also used with the SELECT Clause, although a lot more combinations are possible.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-5-download-the-source-code\">5. Download the Source Code<\/h2>\n<p>This was an example of the SQL SELECT Clause using MySQL RDBMS.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/Queries_SELECT_CLAUSE.zip\"><strong> SQL SELECT Statement Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction In this article, we will look at one of the most used clauses used in SQL known as SELECT. 1.1 What is SQL? In 1974, Donald Chamberlin and Robert Boyce designed a programming language called SQL or &#8220;sequel&#8221;. It is based on relational algebra and tuple-relational calculus. So, this is the programming language &hellip;<\/p>\n","protected":false},"author":232,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[647],"class_list":["post-96939","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql","tag-mysql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SQL SELECT Statement Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"1. Introduction In this article, we will look at one of the most used clauses used in SQL known as SELECT. 1.1 What is SQL? In 1974, Donald Chamberlin and\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL SELECT Statement Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"1. Introduction In this article, we will look at one of the most used clauses used in SQL known as SELECT. 1.1 What is SQL? In 1974, Donald Chamberlin and\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-09T09:00:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Reshma Sathe\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Reshma Sathe\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/\"},\"author\":{\"name\":\"Reshma Sathe\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/079aa9a12c7b8ebea3391ebeb6036a74\"},\"headline\":\"SQL SELECT Statement Example\",\"datePublished\":\"2020-11-09T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/\"},\"wordCount\":881,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"mysql\"],\"articleSection\":[\"sql\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/\",\"name\":\"SQL SELECT Statement Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2020-11-09T09:00:00+00:00\",\"description\":\"1. Introduction In this article, we will look at one of the most used clauses used in SQL known as SELECT. 1.1 What is SQL? In 1974, Donald Chamberlin and\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"sql\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"SQL SELECT Statement Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/079aa9a12c7b8ebea3391ebeb6036a74\",\"name\":\"Reshma Sathe\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/reshma_sathe-96x96.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/reshma_sathe-96x96.png\",\"caption\":\"Reshma Sathe\"},\"description\":\"I am a recent Master of Computer Science degree graduate from the University Of Illinois at Urbana-Champaign.I have previously worked as a Software Engineer with projects ranging from production support to programming and software engineering.I am currently working on self-driven projects in Java, Python and Angular and also exploring other frontend and backend technologies.\",\"sameAs\":[\"www.linkedin.com\/in\/reshma-sathe\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/reshma-sathe\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL SELECT Statement Example - Java Code Geeks","description":"1. Introduction In this article, we will look at one of the most used clauses used in SQL known as SELECT. 1.1 What is SQL? In 1974, Donald Chamberlin and","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:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/","og_locale":"en_US","og_type":"article","og_title":"SQL SELECT Statement Example - Java Code Geeks","og_description":"1. Introduction In this article, we will look at one of the most used clauses used in SQL known as SELECT. 1.1 What is SQL? In 1974, Donald Chamberlin and","og_url":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2020-11-09T09:00:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Reshma Sathe","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Reshma Sathe","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/"},"author":{"name":"Reshma Sathe","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/079aa9a12c7b8ebea3391ebeb6036a74"},"headline":"SQL SELECT Statement Example","datePublished":"2020-11-09T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/"},"wordCount":881,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["mysql"],"articleSection":["sql"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/","url":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/","name":"SQL SELECT Statement Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2020-11-09T09:00:00+00:00","description":"1. Introduction In this article, we will look at one of the most used clauses used in SQL known as SELECT. 1.1 What is SQL? In 1974, Donald Chamberlin and","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/sql-select-statement-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"sql","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/"},{"@type":"ListItem","position":5,"name":"SQL SELECT Statement Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/079aa9a12c7b8ebea3391ebeb6036a74","name":"Reshma Sathe","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/reshma_sathe-96x96.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/reshma_sathe-96x96.png","caption":"Reshma Sathe"},"description":"I am a recent Master of Computer Science degree graduate from the University Of Illinois at Urbana-Champaign.I have previously worked as a Software Engineer with projects ranging from production support to programming and software engineering.I am currently working on self-driven projects in Java, Python and Angular and also exploring other frontend and backend technologies.","sameAs":["www.linkedin.com\/in\/reshma-sathe"],"url":"https:\/\/examples.javacodegeeks.com\/author\/reshma-sathe\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/96939","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/232"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=96939"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/96939\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=96939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=96939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=96939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}