AdBlock Detected!
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.
SQL LIKE |
SQL > SQL Commands >
Like
The LIKE operator is used to filter the result set based on a string pattern. It is always used in the WHERE clause. SyntaxThe syntax for the LIKE operator is as follows: SELECT "column_name"
FROM "table_name" WHERE "column_name" LIKE {PATTERN}; {PATTERN} often consists of wildcards. We saw several examples of wildcard matching in the previous section. ExampleWe use the following table for our example. Table Store_Information
We want to find all stores whose name contains 'AN'. To do so, we key in, SELECT *
FROM Store_Information WHERE Store_Name LIKE '%AN%'; Result:
The "%" sign before 'AN' means that there may be 0, 1, or more characters before the pattern 'AN.' The "%" sign after 'AN' means that there may be 0, 1, or more characters after the pattern 'AN.' Out of the four store names, 'LOS ANGELES,' 'SAN DIEGO,' and 'SAN FRANCISCO' all contain this pattern. ExercisesFor these exercises, assume we have a table called User_Sales with the following data: Table User_Sales
1) 1. Which of the following SQL statement is valid? (There can be more than one answer)
2. How many records will be returned by the following query? (Assuming the database is configured to be case-insensitive)
3. How many records will be returned by the following query? (Assuming the database is configured to be case-insensitive)
|
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.