We can use the LIKE comparison operator to compare partial strings. Two reserved characters are used:

  • % which replaces an arbitrary number of characters
  • _ which replaces a single arbitrary character We can use an escape character to use these, e.g. LIKE '%15\%%'.

Examples:

  • Retrieve all employees whose address is in Houston, Texas.
    SELECT FNAME, LNAME FROM EMPLOYEE WHERE ADDRESS LIKE '%Houston,TX%'
  • Retrieve all employees who were born during the 1950s.
    SELECT FNAME, LNAME FROM EMPLOYEE WHERE BDATE LIKE ’__5_______’