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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.