Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is the use of IN Operator in MySQL?

    • 0
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 112
    Comment on it

    In MySQL, the IN operator is used to allow us specify multiple values in a WHERE clause.

    IN Operator Syntax

    SELECT column_name
    FROM table_name
    WHERE column_name IN (value1,value2,...);
    

    We have a table "employee" as below:

        employee
    
        id  first_name            last_name       country
        .......................................................
        1   John                     Simp         Canada
        2   Chris                    Hely         Canada
        3   Max                      Roy          Korea
        4   Jenny                    Mill         Canada
        5   Jack                     Simpson      London
    

    IN Operator Example

    The below statement selects all employee with a country "Canada" or "Korea":

    SELECT * FROM employee
    WHERE country IN ('Canada','Korea');
    

    Result

        id  first_name            last_name       country
        .......................................................
        1   John                     Simp         Canada
        2   Chris                    Hely         Canada
        3   Max                      Roy          Korea
        4   Jenny                    Mill         Canada
    

    Hope this will help you :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: