How to create a SQL ordering based on JOIN values and on today month

Post Reply

vikasbook
Posts: 1
Joined: Fri Jul 31, 2020 10:00 am

How to create a SQL ordering based on JOIN values and on today month

Post by vikasbook » Fri Jul 31, 2020 10:12 am

I have two databases

TABLE_ORDERS with id,created,user_id.....status_id

Code: Select all

TABLE_STATUSES
with it,title,ordering,month

ordering is an integer for ordering statuses and month is the month number (01-January, 02-February, ...)

I would like to create something like:

Code: Select all

SELECT * 
FROM TABLE_ORDERS, 
     TABLE_STATUSES 
WHERE 1 
  AND TABLE_STATUSES.month >= '7' 
ORDER BY TABLE_STATUSES.ordering
What should be the right syntax?
The wished result is a table of orders ordered by statues like "To be delivered on January, To be delivered on February" that will change automatically month by month in SQL joins.

Thank you for your support!


Post Reply