Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChris Ward
12,129 PointsWhy I am getting this mySQL Warning?
So, I am running a query like this on my database SELECT * FROM table WHERE column LIKE '2015-10-__';
(the table or column name isn't important, so they are omitted) . The purpose of the query is to select all records from October, 2015. Of course, this is working as expected, but it is producing a warning:
mysql> SHOW WARNINGS;
+---------+------+---------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------------------------------+
| Warning | 1292 | Incorrect date value: '2015-10-__' for column at row 1 |
+---------+------+---------------------------------------------------------------------+
1 row in set (0.00 sec)
Does anyone know why I am getting this warning?
2 Answers
Chris Ward
12,129 PointsThe official explanation I got is that this is misapplying types. Dates are optimized to be compared like numbers, so you are going to take a performance hit comparing them as strings.
Luke Pettway
16,593 PointsTry using a % sign instead of the _ underscore. The underscore only allows you to match one character while the percent allows you to do more than one.