1 min read

Select Statement in SQL

The most commonly used SQL command is SELECT statement. It is used to query the database and retrieve selected data that follow the conditions we want.
Select Statement in SQL

In simple words, we can say that the select statement used to query or retrieve data from a table in the database.

Let's see the syntax of select statement.

SELECT expressions FROM tables WHERE conditions;

Here expression is the column that we want to retrieve.

Tables indicate the tables, we want to retrieve records from.

Optional Clauses

[WHERE Clause] : It specifies which rows to retrieve.

[GROUP BY Clause] : Groups rows that share a property so that the aggregate function can be applied to each group.

[HAVING Clause] : It selects among the groups defined by the GROUP BY clause.

[ORDER BY Clause] : It specifies an order in which to return the rows.

For example, let a database table: student_details;

IDFirst_nameLast_nameAgeSubjectHobby
1AmarSharma20MathsCricket
2AkbarKhan22BiologyFootball
3AnthonyMilton25CommerceGambling

SELECT first_name FROM student_details;

Note: the SQL commands are not case sensitive. We can also write the above SELECT statement as:

select first_name from student_details;

Now, you will get following data:

Amar
Akbar
Anthony

SELECT first_name, last_name FROM student_details;

Now, you will get following data:

AmarSharma
AkbarKhan
AnthonyMilton

We can also use clauses like WHERE, GROUP BY, HAVING, ORDER BY with SELECT statement.

SQL SELECT - javatpoint
SQL select query or statement with sql, tutorial, examples, insert, update, delete, select, join, database, table, join
https://www.javatpoint.com/sql-select

#SQL #SELECT #FROM #WHERE #Probyto #ProbytoAI

Subscribe and follow us for latest news in Data Science, Machine learning, technology and stay updated!

Facebook: https://facebook.com/probyto
Twitter: https://twitter.com/probyto
LinkedIn: https://linkedin.com/company/probyto
Instagram: https://instagram.com/probyto