• SQL LIKE Operator – SQL TUTORIAL | Software Testing Material

    SQL LIKE Operator:

    The SQL LIKE operator is used in a WHERE clause to compare a value to similar values using wildcard operators.

    There are two wildcard operators used in conjunction with the Like operator.

    Percentage sign ( % )

    Underscore sign ( _ )

    SQL LIKE Syntax:

    Example – Like Operator:

    In the below image, you could find two SELECT queries. First SELECT query returns the complete records of the table SCOREBOARD where as the second SELECT query returns the values only if the Playername is Sachin. We used WHERE clause in the second SELECT query with the LIKE operator.

    SQL Like

    Example – Like Operator with Wildcard %:

    In the below image, you could find two SELECT queries. First SELECT query returns the complete records of the table SCOREBOARD where as the second SELECT query returns the values only if the Playername starts with letter D. We used WHERE clause in the second SELECT query with the LIKE operator and wildcard %.

    SQL Like Operator With Wildcard

    Example – Like Operator with Wildcard % At The Beginning:

    In the below image, you could find two SELECT queries. First SELECT query returns the complete records of the table SCOREBOARD where as the second SELECT query returns the values only if the Playername consists the letter h. We used WHERE clause in the second SELECT query with the LIKE operator and wildcard before and after the letter h

    SQL Like Operator With Wildcard At The Begining

    Example – Like Operator with Wildcard _:

    Example – Like Operator with Wildcard _ Before And After:

    Example – Like Operator with Wildcard combination % and _:

    NOT LIKE:

    In the below image, you could find two SELECT queries. First SELECT query returns the complete records of the table SCOREBOARD where as the second SELECT query returns the values from the tables but it eliminates the values which has letter SacWe used WHERE clause in the second SELECT query with the NOT LIKE operator and the letters Sac with wild card % before and after the letters Sac.

    SQL Not Like

    In the next tutorial, we will see How To Use IN OPERATOR in SQL

    Check out the complete SQL Tutorial by clicking on below link:

    SQL Tutorial – Complete

    Sharing is caring.

    Share on facebook
    Facebook
    Share on twitter
    Twitter
    Share on linkedin
    LinkedIn

    Like This Post?

    We have a lot more where that came from?

    We only send really good stuff occasionally, promise.

    Rajkumar SM

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    Share on facebook
    Share on google
    Share on twitter
    Share on linkedin
    Share on whatsapp

    Recent Posts:

    Scroll to Top
    API Testing eBook

    DOWNLOAD FOR FREE