1
檢查下面的代碼只得到一年:如何從日期CakePHP中使用不同於MySQL的
$this->set('hi', $this->posts->find('all',
array('fields'=>array('DISTINCT year(posts.Post_date)'))));
,我沒有得到正確的結果...誰能幫我在這,請...
我的查詢是(從帖子中選擇不同年份(post_date));
感謝
檢查下面的代碼只得到一年:如何從日期CakePHP中使用不同於MySQL的
$this->set('hi', $this->posts->find('all',
array('fields'=>array('DISTINCT year(posts.Post_date)'))));
,我沒有得到正確的結果...誰能幫我在這,請...
我的查詢是(從帖子中選擇不同年份(post_date));
感謝
下面替換下面
`DISTINCT year(posts.Post_date)`
: -
YEAR(DISTINCT posts.Post_date) as year
@saimurali如果這個答案可以幫助你然後PLZ接受這個答案。 – ripa
使用的格式(字段名, 'Y')作爲你的約會 –
http://dev.mysql.com /doc/refman/5.1/en/string-functions.html#function_format –
同時檢查您的大小寫,您可能需要將「posts.Post_date」替換爲「Posts.post_date」。 –