If you don't use a wildcard (%), you're basically checking if both are the same.
In other words:
WHERE `ColumnName` LIKE 'Value'
is the same as:
WHERE `ColumnName` = 'Value'
(you only find the records where 'Value' and the contents of the column are exactly the same)
If you want to find records where ColumnName
contains that value, you'll need to use wildcards:
WHERE `ColumnName` LIKE '%Value%'
If you only want to find records where the value of ColumnName
starts with 'Value' (in other words, there shouldn't be anything in front of it), use:
WHERE `ColumnName` LIKE 'Value%'
Example
Let's consider this table (called myTable):
ID | Description
----------------
1 | Lorem Ipsum dolar sit amet
2 | Lorem ipsum FooBar dolar sit amet
3 | FooBar
4 | Foo Bar
Now this query:
SELECT *
FROM `myTable`
WHERE `Description` LIKE '%FooBar%'
will return rows #2 and #3.
Row #1 will not be returned because it doesn't contain 'FooBar'.
Row #4 will not be returned because it doesn't contain 'FooBar', either. (it does contain 'Foo Bar', but that's not the same)
Now let's see what happens using another query:
SELECT *
FROM `myTable`
WHERE `Description` LIKE 'FooBar%'
(note that the %
before FooBar has been removed)
This query will only return row #3, because that's the only row that starts with FooBar.