Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

Filtering - WHERE clause

To select the rows meeting only certain criteria, use WHERE clause.
Syntax:

SELECT col1,col2 FROM table1 WHERE conditon1 AND/OR condition2 .....
SELECT col1,col2 FROM table1 WHERE (col1='123' and col2='456') OR col3='4';

Operators:

  • Equal to: A = B
  • Not equal to: A != B
  • Greater than: A > B
  • Less than: A < B
  • Greater than or equal to: A >= B
  • Less than or equal to: A <= B
  • Between 2 values including the values: BETWEEN A and B
  • Like (contains): A like %aker%

Example:

select * from deptt where depcity = 'Mumbai';
select * from emp where empsal > 2300;
select * from emp where empsal between 2400 and 2600;

All these operators can be used on the number as well as strings. When needed, numbers are implicitly converted into strings before comparison.

select * from deptt where depid like '%3%';
select * from deptt where depid like '%x%';
select * from deptt where depid = 'hello';

This 'where' clause can be used in insert/update/delete statements too.


No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...