SELECT Query in DBMS

About SELECT Query in DBMS

In this article, we will learn about SELECT Query in DBMS.
Queries in DBMS are commands which helps to request and retrieve data from the database uisng a proper soecified and sequential format.They are used to fetch data from the tables in which the data is stored.

 

Select query in dbms

SELECT Query in DBMS

 

  • A SELECT  query is used to retrieve data(records) from the table
  • We can retrieve complete table data, or specific records by specifying conditions using the WHERE clause.

Syntax 

SELECT column1, column2, ...
FROM table_name;

Displaying only specific columns using SELECT Query in DBMS

Consider a table student where you need to display a student name, ID, and score

SELECT stuid,sname,score 
from student;
O/P
stuid sname score
66 Trishaank 92
82 Srinivas 62
73 Prashanth 78
79 Sanjay 85
91 Chandana 90

Display all records present in the table using SELECT Query in DBMS

The ‘*’ operator is used to display  all the columns present in the table

SELECT * from student;
stuid sname branch dob score
66 Trishaank computers 24-07-1998 92
82 Srinivas computers 7-07-1996 62
73 Prasanth Physics 17-08-1997 78
79 Sanjay Maths 12-09-1997 85
91 Chandana Biology 7-05-1997 90

All the columns in the table get displayed.

 Retrieve  records based on some specified condition

Only those records that satisfy the condition specified in the ‘where’ clause are displayed

Display records of those students from the computers department

SELECT * from
student
where branch='computers';
O/P
stuid sname branch dob score
66 Trishaank computers 24-07-1998 92
82 Srinivas computers 7-07-1996 62

Performing some calculations on the column using SELECT

  • We can use simple arithmetic operators upon column data while displaying records
  • But these changes are not affected in the actual database table they are just  used for display purpose

Increase score of students by 5 marks who are having a score greater than 80

SELECT stuid,sname,score,score+5 
from student
where score>80;
O/P
stuid sname score score+5
66 Trishaank 92 97
79 Sanjay 85 90
91 Chandana 90 95
5 marks will be added to all students who are having ‘score’ greater than 80 are displayed

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription

One comment on “SELECT Query in DBMS”