How to create a SQL ordering based on JOIN values and on today month
Posted: Fri Jul 31, 2020 10:12 am
I have two databases
TABLE_ORDERS with id,created,user_id.....status_id
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:
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!
TABLE_ORDERS with id,created,user_id.....status_id
Code: Select all
TABLE_STATUSES
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?
Thank you for your support!