Is there any difference between:
SELECT * FROM users WHERE username="davyjones"
and
SELECT * FROM users WHERE username LIKE "davyjones"
1 Answer. Using '=' operator is faster than the LIKE operator in comparing strings because '=' operator compares the entire string but the LIKE keyword compares by each character of the string. We can use LIKE to check a particular pattern like column values starting with 'abc' in this case.
There is no combination of LIKE & IN in SQL, much less in TSQL (SQL Server) or PLSQL (Oracle). Part of the reason for that is because Full Text Search (FTS) is the recommended alternative.
Example. Other than the difference of having wildcard characters, %, and _, there is a significant difference between LIKE and = operators is that LIKE operator does not ignore the trailing spaces while = operator ignores the trailing spaces.
The keyword ILIKE can be used instead of LIKE to make the match case insensitive according to the active locale. This is not in the SQL standard but is a PostgreSQL extension. The operator ~~ is equivalent to LIKE , and ~~* corresponds to ILIKE .
LIKE
allows partial matching / use of wildcards, while =
checks for exact matches.
For example
SELECT * FROM test WHERE field LIKE '%oom';
Will return rows where field value is any of the following:
Zoom, Boom, Loom, Groom
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With