What's the difference between "LIKE" and "=" in SQL?

aviraldg picture aviraldg · Oct 1, 2009 · Viewed 54.8k times · Source

Is there any difference between:

SELECT * FROM users WHERE username="davyjones"

and

SELECT * FROM users WHERE username LIKE "davyjones"

Answer

code_burgar picture code_burgar · Oct 1, 2009

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