我的表上有一个名为 X 的字段,我存储 unixtime(php -> time())。 我的问题是:
How can I list all the months from my DB, something like: 6.2009 8.2009 etc..
我的第二个问题是:
How can I make a query to list all the informations based on a month and year on the same field X(i store unixtime), I know this doesn't work, but mabe you can understand it better: where
date
= '06.2009'
有什么解决办法吗?
最佳答案
列出所有月份:
SELECT DISTINCT EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(X)) FROM MyTable;
返回给定年份和月份的所有行:
SELECT * FROM MyTable WHERE EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(X)) = 200906;
关于php - Unixtime 和 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1303377/