Where the reference ID refers to the ID in the data_table.
I need a query to get the IDs from the Data_table in the order defined in the sort_table, but if anything from the data_table doesn't show up in the sort_table I want it to show up at the end like this:
3251 -- this isn't in sort_table4 -- this isn't in sort_table
Please note the NULL value can be sorted differently depending on SQL engine used. If values missing in the Sort_table are at the top you may use different expression in ORDER BY, e.g.:
ORDER BY -s.order DESC, d.ID
Also the [order] column name must be enclosed in brackets in some SQL engines...