When to invoke LIKE or = in a WHERE clause


Is there a rule stating when to use LIKE and when to use the equal sign in a WHERE clause?


They are both operators of the WHERE clause. When we are matching a specific value, we can use = or even IS,

WHERE id = 1


WHERE city IS 'Pittsburgh'

When we just want a similarity,

WHERE sport is LIKE '%ball'

Note the wild-card (%) at the beginning of the string. This will match any string value that ends with ball.