Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8876335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:11:25+00:00 2026-06-14T19:11:25+00:00

i have a table with date(actually they are string time in this format: 2004-Mar).

  • 0

i have a table with date(actually they are string time in this format: 2004-Mar). I want to rank the record based on this date, so i have the following query:

SELECT *,STR_TO_DATE(detail,'%Y-%b') 
FROM table2 JOIN user_table 
ON table2.user_id = user_table.id 
ORDER BY STR_TO_DATE(detail,'%Y-%b') DESC 
WHERE table2_col = 11;

But this query doesn’t work, it asks me to check syntax err near ‘WHERE table2_col = 11’ at line 5

If i delete ORDER BY STR_TO_DATE(detail,’%Y-%b’) DESC , then everything works fine. so i think the error comes from str_to_date? what’s wrong with my code?
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:11:26+00:00Added an answer on June 14, 2026 at 7:11 pm

    The order by should come after the where clause

    Try this::

    SELECT *,STR_TO_DATE(detail,'%Y-%b') 
    FROM table2 JOIN user_table 
    ON table2.user_id = user_table.id 
    
    WHERE table2_col = 11
    ORDER BY STR_TO_DATE(detail,'%Y-%b') DESC 
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table with date/time column and person column. Each person has multiple records
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have table with one of the columns as date in 'YYYY-MM-DD' format. Can
I have this table: ID(INT) DATE(DATETIME) Under the DATE column there are a lot
I have a table (several actually) that I want to get results from with
Say I have a table named Storage with records this kind Item_Id | Date
I have a table that looks like this: -------------------------------------------- | Date | House# |
Imagine I have following table: NAME DATE OTHER_CONTANT 'A' '2012-06-05' 'baz' 'A' '2012-06-04' 'bar'
If I have table with a Date column called myDate , with values like
I have the following SQL table - Date StoreNo Sales 23/4 34 4323.00 23/4

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.