suyesh.amatya Posted August 6, 2008 Share Posted August 6, 2008 table name:blog column_name(date_of_post) 2007-07-06 10:43:22 2008-08-06 10:43:50 2008-06-06 10:48:30 2008-05-06 10:53:13 2008-08-06 14:30:18 Now i need to select the distinct month,year merged into the same field.I have a query which gives that but in two different fields. SELECT DISTINCT MONTH(date_of_post) AS month, YEAR(date_of_post) AS year FROM blog order by year desc, month desc Link to comment https://forums.phpfreaks.com/topic/118419-query-help/ Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 Not exactly sure what you mean, but look into UNION and JOIN ---------------- Now playing: Enter Shikari - Keep It On Ice (Zane Lowe BBC Session) via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118419-query-help/#findComment-609494 Share on other sites More sharing options...
PFMaBiSmAd Posted August 6, 2008 Share Posted August 6, 2008 If you would state how you want the results formatted (yyyy-mm or yyyymm) someone could directly provide an answer, but one of the following could be used, either by itself or within your existing query (all are mysql functions) - EXTRACT() LEFT() DATE_FORMAT() CONCAT() Link to comment https://forums.phpfreaks.com/topic/118419-query-help/#findComment-609823 Share on other sites More sharing options...
fenway Posted August 6, 2008 Share Posted August 6, 2008 You can EXTRACT the YEARMONTH. Link to comment https://forums.phpfreaks.com/topic/118419-query-help/#findComment-609917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.