When to invoke LIKE or = in a WHERE clause


#1

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


#2

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

WHERE id = 1

or

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.