LIKE

 

LIKE


The LIKE operator is extremely useful for working with text. You will use LIKE within a WHERE clause. The LIKE operator is frequently used with %. The % tells us that we might want any number of characters leading up to a particular set of characters or following a certain set of characters.
Remember you will need to use single quotes for the text you pass to the LIKE operator, because of this lower and uppercase letters are not the same within the string. 

Questions using the LIKE operator


Use the accounts table to find


  1. All the companies whose names start with 'C'.

  2. All companies whose names contain the string 'one' somewhere in the name.

  3. All companies whose names end with 's'.

Solutions for LIKE operator


  1. SELECT name FROM accounts WHERE name LIKE 'C%';
  2. SELECT name FROM accounts WHERE name LIKE '%one%';
  3. SELECT name FROM accounts WHERE name LIKE '%s';

Comments

Popular posts from this blog

Entity Relationship Diagrams

Arithmetic Operators

NOT