πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

SQL SELECT Statement

SQL SELECT Statement

In SQL, the SELECT statement is used to query or retrieve data from a table in the database. The returns data is stored in a table, and the result table is known as result-set.

Syntax

  1. SELECT column1, column2, ...  
  2. FROM table_name;  

Here, the expression is the field name of the table that you want to select data from.

Use the following syntax to select all the fields available in the table:

  1. SELECT  *  FROM table_name;  

Example:

EMPLOYEE

EMP_IDEMP_NAMECITYPHONE_NOSALARY
1KristenChicago9737287378150000
2RussellAustin9262738271200000
3AngelinaDenver9232673822600000
4RobertWashington9367238263350000
5ChristianLos angels7253847382260000

To fetch the EMP_ID of all the employees, use the following query:

  1. SELECT EMP_ID FROM EMPLOYEE;  

Output

EMP_ID
1
2
3
4
5

To fetch the EMP_NAME and SALARY, use the following query:

  1. SELECT EMP_NAME, SALARY FROM EMPLOYEE;  
EMP_NAMESALARY
Kristen150000
Russell200000
Angelina600000
Robert350000
Christian260000

To fetch all the fields from the EMPLOYEE table, use the following query:

  1. SELECT * FROM EMPLOYEE  

Output

EMP_IDEMP_NAMECITYPHONE_NOSALARY
1KristenChicago9737287378150000
2RussellAustin9262738271200000
3AngelinaDenver9232673822600000
4RobertWashington9367238263350000
5ChristianLos angels7253847382260000

Labels: ,

Discussion & Queries (<$I18NNumComments$>):

<$CommentPager$>
<$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>

<$BlogCommentBody$>

<$BlogCommentDeleteIcon$>
<$CommentPager$>