Sql Select Where Clause Examples – Query Examples

Sql Select Where Clause Examples

Sql Select Where Clause

  • We use where clause to specify conditions
  • Only if we have conditions we can write where statement
  • Where clause can be used with SELECT, UPDATE, and DELETE statements.
  • According to the conditions, ‘where statement’ returns true or false value
  • If value returns true, that record is listed

In Where Clause we can use operators and statements that specified below

  • > bigger
  • < small
  • >= bigger or equal
  • <= small or equal
  • = equal
  • != not equal
  • between x and y
  • like
  • in
  • is null

TO DOWNLOAD THE SAMPLE LİBRARY DATABASE CLICK

Sql Where Clause Examples on Library Database

Sample 1: List the student where student_id equal to 20

Result Of The Query

1 row listed.

Sample 2: List the books where page count bigger than 200

96 rows listed.

Sample 3: List the books where the point value smaller than 120

Result Of The Query

168 rows listed.

Sample 4: List the books where pageCount in between 100 and 200

Result Of The Query

61 rows listed.

Sample 5: List the students where student name starts with “a” character

Result Of The Query

126 rows listed.

Sample 6: List the students who are in 11A class or 11B class

Result Of The Query

42 rows listed.

Sample 7: List the boys from 11a or 11b

Not: Brackets are very important. Detailed information will be written in the subject of operators

Result Of The Query

25 rows listed.

Sample 8:List the students where name contains “b” character and student id in between 100 and 200

Result Of The Query

17 rows listed.

Sample 9:List the students whose second character of name is a.

Result Of The Query

141 rows listed.

Sample 10:List the students whose second character of name from end is “a”.

Result Of The Query

29 rows listed.

YOU MAY WANT TO SEE OUR ALL EXAMPLES PAGE, THEN CLICK HERE

About the author

admin

Leave a Comment

%d bloggers like this: