Home SQL Basic SQL IN
SQL IN

The SQL IN keyword allow us to select specific information when we know what we are looking for. It enables us to specify mutiple values in the where statement instead of using many OR operator.

SYNTAX:

    
SELECT "column_name"
    FROM Student
    WHERE CourseName IN ('value1', 'value2')

Table: Student

StudentID LastName FirstName DOB CourseFees CourseName
1 John Astone 07/15/1976 1000.00 Accountant
2 Bob Eastwood 02/13/1935 1500.00 Economic
3 Jane Hollywood 03/23/1939 2000.00 IT
4 Bob Eastwood 03/19/1980 3000.00 Economic


We can place as many values as needed inside the parenthesis, each values must be seperated by the commas. The values can be in the form of characters or numerical.For example if we wants to select all the student record who studies Accountant or Economic in the Student table we would issue the following statement:

EXAMPLE #1

    
SELECT *

    FROM Student

    WHERE CourseName IN ('Accountant', 'Economic')

RESULT:

StudentID LastName FirstName DOB CourseFees CourseName
1 John Astone 07/15/1976 1000.00 Accountant
2 Bob Eastwood 02/13/1935 1500.00 Economic
4 Bob Eastwood 03/19/1980 3000.00 Economic

EXAMPLE #2
    

    SELECT *

    FROM Student

    WHERE DOB IN ('07/15/1976', '03/19/1980')

RESULT:


StudentID LastName FirstName DOB CourseFees CourseName
1 John Astone 07/15/1976 1000.00 Accountant
4 Bob Eastwood 03/19/1980 3000.00 Economic




Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

"