When using SQL, are there any benefits of using =
in a WHERE
clause instead of LIKE
?
Without any special operators, LIKE
Using = avoids wildcards and special characters conflicts in the string when you build the query at run time.
This makes the programmer's life easier by not having to escape all special wildcard characters that might slip in the LIKE clause and not producing the intended result. After all, = is the 99% use case scenario, it would be a pain to have to escape them every time.
rolls eyes at '90s
I also suspect it's a little bit slower, but I doubt it's significant if there are no wildcards in the pattern.