Jump to content

query help


suyesh.amatya

Recommended Posts

  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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.