Querying Data from Single Table: You can use the SQL LIKE operator to find records that match a certain pattern in a database. It works well with the SELECT, UPDATE, and DELETE statements to filter the data based on the pattern you specify.
SQL LIKE Operator
— 1. “%” is the operator to get values based on conditions.
— 2. See 1st query (b%) indicates “get all the values starts with letter ‘b’ and end with any number of characters. (It doesn’t matter, whether it lower or upper case).
— 3. See 1st query if we specify (%b) then it indicates “get all the values end with letter ‘b’ and can begin with any number of characters. (It doesn’t matter, whether it lower or upper case).
— 4. See 2nd query (%b%) indicated “get all values which have “b” anywhere. (It returns any number of characters after or before “b”).
— 5. See 3rd query (_y) means “get one character before “y” (The number of underscores you specify, it will count and return the character).
— 6. My name is Vickey then, operator is used as (_____y). It will return values based on underscore and the letter you specify at last. For more click here!
SQL Example 1:
SELECT *
FROM customers
WHERE last_name LIKE 'b%';
SQL Example 2:
SELECT *
FROM customers
WHERE last_name LIKE '%b%';
SQL Example 3:
SELECT *
FROM customers
WHERE last_name LIKE '_____y';
Watch Video!
Next Post >> #2.8) SQL REGEXP Operators
<<Previous Post #2.6) BETWEEN Operators