• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
EDUCBA

EDUCBA

MENUMENU
  • Resources
        • Java Tutorials

          • Cheat Sheet Java
          • Cheat Sheet Python
          • C# vs Js
        • Java Tutorials
        • Python Tutorials

          • Angular 5 vs Angular 4
          • Careers in Python
          • Kali Linux vs Ubuntu
        • Python Tutorials
        • Top Differences

          • Cheat Sheet JavaScript
          • Python Interview Questions
          • Cloud Computing or Virtualization
        • Top Differences
        • Others

          • Resources (A-Z)
          • Top Interview Question
          • Programming Languages
          • Web Development Tools
          • HTML CSS Tutorial
          • Technology Basics
          • Technology Careers
          • View All
  • Free Courses
  • All Courses
        • Certification Courses

          Software Development Course 2
        • All in One Bundle

          All-in-One-Software-Development-Bundle
        • Become a Python Developer

          Python-Certification-Training
        • Others

          • Java Course
          • Become a Selenium Automation Tester
          • Become an IoT Developer
          • Ruby on Rails Course
          • Angular JS Certification Training
          • View All
  • 600+ Courses All in One Bundle
  • Login

SQL SELECT Query

Home » Software Development » Blog » SQL Tutorials » SQL SELECT Query

sql select query

Introduction to SQL SELECT Query

Before jumping to discuss the SQL select query let’s begin with the SQL first. SQL stands for Structured Query Language. SQL is a query language that enables the ability to do various operations on the database or the database tables. There are various ways to interact with the database tables. The select command is nothing but it’s all about how we communicate with the database and its table for selecting the required records. This is a way of selecting the records from one or more tables. We can use the select query in many ways, few of them are easy and few are from the complex side. In this article, we will see the various uses of the select statements.

Syntax

Select is one of the basic commands of the relational database management system. We can use the SELECT keyword as a prefix to select the record(s) from a given table. The select query return set of records from the given one or more tables.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

1. Selecting the required columns of a given table:

SELECT <column_A>, <column_B>, ...... FROM <My_table_name>;

Explanation:

SELECT  is a command itself, we can use it to select the record from the table.

<column_A>, <column_B>, …… are the columns of the table My_table_name.

<My_table_name> is the name of a table.

2. Selecting all the columns of a table:

SELECT * FROM <My_table_name>;

Explanation:

SELECT  is a command itself we can use to select the record from the table.

* denotes all the columns of the given table.

<My_table_name> is the name of a table.

3. Selecting the records with the WHERE clause:

SELECT <column_One>, <column_Two>, ...... FROM <My_table > WHERE <column_ One > = <Column_Value>;

Explanation:

<column_One>, <column_Two>, …… are the columns of the table My_table.

<My_table > is the name of a table.

WHERE is a keyword we can use in the SQL select statement to select the records by the specified condition.

4. Selecting the number of records:

SELECT  COUNT(*)  FROM <My_table>;

Explanation:

COUNT(*), this will give us the total number of rows of the table My_table.

<My_table > is the name of a table.

Examples of SQL SELECT Query

In this section, we will discuss some examples, considering the syntax mentioned above so that anyone can easily understand by putting little effort. Let’s practice some example to understand the SQL select statement better.

Suppose we have a database name “SCHOOL”. This database has tables as mentioned below:

Students

Student Table

Class

Class

1. SELECT with required columns example:

SELECT Student_ID, First_name, Last_name from Student;

Output:

SQL Select Query- Column example

SELECT Student_ID, Class from Class;

Output:

column example output

2. SELECT all the columns of a table  example:

SELECT * from Student;

Output:

SQL Select Query - Table example

SELECT * from Class;

Output:

Table example output
3. Selecting the records with WHERE clause example 

SELECT * from Student WHERE First_name="Alex";

Output:

SQL SELECT Query - clause example

SELECT * from Class where Medium=' English ';

Output:

clause example output

4. Selecting the number of records example:

SELECT COUN(*) as count  from Student;

Output:

Record example output

SELECT COUN(*) as count  from Class;

Output:

Output

Other Facts about the SQL SELECT

The select statement mentioned above can be performed on the relational database. There are various other select statement queries we can use to select the records. The select statement always returns a result set. This result set may contain zero (0), one or multiple records as well. There are various other things in the select statement we can use to get the desired result. We can use the JOIN keyword to select the records from two or more tables. There are various ways, we can use two or more select statements together to get the records from one or more tables. We should use a primary key to any table so that a record can be identified uniquely.

We can use the below mentioned optional clause with the SELECT statement:

  • WHERE – we have already seen this with examples.
  • GROUP BY – This is required before using the aggregate function.
  • HAVING – We can perform an aggregate function using this over the GROUP BY statement.
  • ORDER BY – We can use this with the SELECT to sort the order of the result set.
  • AS – We have seen this while selecting the total records of a given table. This AS can be used to make an alias of either the selected column or the table.

Conclusion – SQL SELECT Query

We can use the SQL select statement to select the required columns or the records as per the business need. Almost every relational database has this SELECT command to select the record from the table. We can use select in various ways. We can select conditional based records. The select operation can be performed on one or more tables. We can combine various other commands with the SELECT statements. MySQL, ORACLE are examples of the relational database management system.

Recommended Articles

This is a guide to SQL SELECT Query. Here we discuss the introduction, syntax, examples and some other facts about the SQL Select Query. You may also look at the following articles to learn more –

  1. SQL Insert Query
  2. MySQL Query Commands
  3. Database in SQL​ 
  4. Table in SQL

All in One Software Development Bundle (600+ Courses, 50+ projects)

600+ Online Courses

50+ projects

3000+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Reader Interactions
Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar
Technology Blog Tutorials
  • SQL Tutorial
    • MySQL Queries
    • PL/SQL Data Types
    • Joins in MySQL
    • GROUP BY clause in SQL
    • SQL WHERE Clause
    • SQL Constraints
    • Jspinner
    • SQL SELECT Query
    • Cursors in PL/SQL
    • SQL Date Function
    • Cursors in SQL
    • CASE statement in PL/SQL
    • MS SQL Interview Questions
    • SQL Joins Interview Questions
    • Wildcards in MySQL
    • Table in SQL
    • Wildcard Characters
    • SQL Alter Command
    • Transactions in SQL
    • Foreign Key in SQL
    • First Normal Form
    • SQL Insert Query
    • Types of Joins in SQL
    • ORDER BY Clause in SQL
    • Wildcard in SQL
    • Database in SQL?
    • What is PL/SQL?
    • PostgreSQL Data Types
    • Second Normal Form
    • Advantages of DBMS
    • Introduction To DBMS
    • Hierarchical Database Model
    • What is Procedure in SQL
  • Database Management (71+)
  • Ethical Hacking Tutorial (33+)
  • HTML CSS Tutorial (47+)
  • Installation of Software (54+)
  • Top Interview question (188+)
  • Java Tutorials (196+)
  • JavaScript (71+)
  • Linux tutorial (32+)
  • Network Security (85+)
  • Programming Languages (232+)
  • Python Tutorials (89+)
  • Software Development Basics (321+)
  • Software Development Careers (38+)
  • String Functions (12+)
  • Technology Commands (38+)
  • Top Differences (368+)
  • Web Development Tools (33+)
  • Mobile App (60+)
Technology Blog Courses
  • JDBC Training Course
  • PHP course
  • Windows 10 Training
Footer
About Us
  • Who is EDUCBA?
  • Sign Up
  •  
Free Courses
  • Free Course Programming
  • Free course Python
  • Free Course Java
  • Free Course Javascript
  • Free Course on SQL
  • Free Course on Web Design
  • Free HTML Course
  • Free Android App Development Course
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • Ruby on Rails Course
  • ASP.NET Course
  • VB.NET Course
  • Bootstrap Training Course
  • Become a Linux System Administrator
  • PHP Course
  • Joomla Training
  • HTML Course
Resources
  • Resources (A To Z)
  • Java Tutorials
  • Python Tutorials
  • Top Differences
  • Top Interview Question
  • Programming Languages
  • Web Development Tools
  • HTML CSS Tutorial
  • Technology Basics
  • Technology Careers
  • Ethical Hacking Tutorial
  • SQL Tutorials
  • Digital Marketing
Apps
  • iPhone & iPad
  • Android
Support
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions

© 2019 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Let’s Get Started
Please provide your Email ID
Email ID is incorrect

Limited Period Offer - All in One Software Development Bundle (600+ Courses, 50+ projects) View More

Limited Period Offer - Limited Period Offer - All in One Software Development Bundle (600+ Courses, 50+ projects) View More