Search code examples
mysqlsql-like

Problems with "LIKE' in MySQL Workbench


I'm not sure if I'm missing something here, because I'm a rookie, but I'm having trouble with "LIKE" in MySQL workbench.

I have a column in one of my tables that has three letters, and then the date (in this case, 06-10-2013), so it looks like this: AAA201306100. I'm trying to write a query that will return only results where the date is from 2014.

So far, I've tried:

SELECT *
FROM 'table'
WHERE 'column_id' LIKE %2014%

and have received and error every time. Where am I going wrong? Thanks!


Solution

  • You're missing quotes around the year. Even though it's a number it is stored in the table as a string.

    Try this:

    SELECT *
    FROM 'table'
    WHERE 'column_id' LIKE '%2014%'