Page 137 - SQL
P. 137

SELECT * FROM Employees WHERE Fname LIKE '[lmnop]ary'


        The range or set can also be negated by appending the ^ caret before the range or set:


        This range pattern would not match "gary" but will match "mary":


         SELECT * FROM Employees WHERE FName LIKE '[^a-g]ary'


        This set pattern would not match "mary" but will match"gary":


         SELECT * FROM Employees WHERE Fname LIKE '[^lmnop]ary'


        Match ANY versus ALL


        Match any:
        Must match at least one string. In this example the product type must be either 'electronics',
        'books', or 'video'.


         SELECT *
         FROM   purchase_table
         WHERE  product_type LIKE ANY ('electronics', 'books', 'video');


        Match all (must meet all requirements).
        In this example both 'united kingdom' and 'london' and 'eastern road' (including variations) must be
        matched.


         SELECT *
         FROM   customer_table
         WHERE  full_address LIKE ALL ('%united kingdom%', '%london%', '%eastern road%');


        Negative selection:
        Use ALL to exclude all items.
        This example yields all results where the product type is not 'electronics' and not 'books' and not
        'video'.


         SELECT *
         FROM   customer_table
         WHERE  product_type NOT LIKE ALL ('electronics', 'books', 'video');



        Search for a range of characters


        Following statement matches all records having FName that starts with a letter from A to F from
        Employees Table.


         SELECT * FROM Employees WHERE FName LIKE '[A-F]%'


        ESCAPE statement in the LIKE-query




        https://riptutorial.com/                                                                             119
   132   133   134   135   136   137   138   139   140   141   142