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 Quote Link to comment 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 Quote Link to comment 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() Quote Link to comment Share on other sites More sharing options...
fenway Posted August 6, 2008 Share Posted August 6, 2008 You can EXTRACT the YEARMONTH. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.