开发者

how to select a period of time in mysql?

开发者 https://www.devze.com 2023-01-24 03:38 出处:网络
I want to make a MySql selection for a period of time. but i didn\'t figure it out how to make it correctly.

I want to make a MySql selection for a period of time. but i didn't figure it out how to make it correctly.

this is what i tried

SELECT * FROM rapoa开发者_Go百科rte WHERE DATE(ziua) BETWEEN 2010-01-12 AND 2011-01-14

Can you please help?

thanks, Sebastian


If performance is an issue I would avoid using DATE in this way as it will prevent efficient usage of an index and will result in a full scan. For small tables this might not be a problem but if your table is large you will probably find that this gives better performance:

SELECT *
FROM rapoarte
WHERE ziua >= '2010-01-12'
AND ziua < '2010-01-15'


SELECT * FROM rapoarte WHERE DATE(ziua) BETWEEN "2010-01-12" AND "2011-01-14"
0

精彩评论

暂无评论...
验证码 换一张
取 消