Posted by AnithaKamatchi on Thursday, March 02, 2017 in SQL | No comments
Usage :
Extract the data from the database which matches desired criteria
General Syntax:
General Syntax:
Select * from table <table_name> where <condition>
How the SELECT with WHERE clause works????
Consider the table "Student_List" as shown below
Case 1:
Retrieve all the rows in the table "Student_List" with "Student_Age" equals 10
Syntax:
Select * from table <table_name> where <column_name> = <value>
Actual Query:
Select * from table Student_List where Student_Age = 10
Result:
Note: we can use all relational operation such as >,<,>=,<=,<> in where condition
Case 2:
Retrieve all the rows in the table "Student_List" with "Skills" matching 'Singing' or 'Dancing'
Syntax:
Select * from table <table_name> where <column_name> in (<value 1>,<value 2>...<value n>)
Actual Query:
Select * from table Student_List where Skills in ('Singing','Dancing')
Result:
Note: Strings should be enclosed within single quotes (like 'Singing','Dancing' in above case)
Case 3:
Retrieve all the rows in the table "Student_List" with "Student_Age" between 6 to 10
Syntax:
Select * from table <table_name> where <column_name> between <value 1> and <value 2>
Actual Query:
Select * from table Student_List where Student_Age between 6 and 10
Result:

0 comments:
Post a Comment