SQLite WHERE Clause

The SQLite WHERE clause is generally used with SELECT, UPDATE and DELETE statement to specify a condition while you fetch the data from one table or multiple tables.

If the condition is satisfied or true, it returns specific value from the table. You would use WHERE clause to filter the records and fetching only necessary records.

WHERE clause is also used to filter the records and fetch only specific data.

Syntax:

snippet
SELECT column1, column2, columnN 
FROM table_name
WHERE [condition]

Example:

In this example, we are using WHERE clause with several comparison and logical operators. like >, <, =, LIKE, NOT, etc.

We have a table student having the following data:

Sqlite Where clause 1

Example1:

Select students WHERE age is greater than or equal to 25 and fees is greater than or equal to 10000.00

snippet
SELECT * FROM STUDENT WHERE AGE >= 25 AND FEES >= 10000.00;

Output:

Sqlite Where clause 2

Example2:

Select students form STUDENT table where name starts with 'A' doesn't matter what come after 'A'.

snippet
SELECT * FROM STUDENT WHERE NAME LIKE 'A%';

Output:

Sqlite Where clause 3

Example3:

Select all students from STUDENT table where age is either 25 or 27.

snippet
SELECT * FROM STUDENT WHERE AGE IN ( 25, 27 );

Output:

Sqlite Where clause 4

Example4:

Select all students from STUDENT table where age is neither 25 nor 27.

Output:

Sqlite Where clause 5
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +