I want to write a query to find all the items in my 'schedule_items' table that match a YYYY-MM-DD value of a DATETIME field.
something like: SELECT * FROMschedule_itemsWHEREstart?matches? '$date'
Where start would be a DATETIME field with data like 2009-09-23 11:34:00 and $date would be something like 2009-09-23
Can I do this or do I need to load all the values and then explode and compare the values in my DATETIME start field?
你可以在MySQL中使用LIKE
SELECT * FROM schedule_items WHERE start LIKE 'some-date%'
Run Code Online (Sandbox Code Playgroud)
您将%符号作为通配符.
请注意,虽然这可能是一个非常沉重的查询.特别是如果在字符串的开头使用%.