Skip to content
Advertisement

sort table from another table with union and join

Given the following tables, I would like the final output to be sorted by department weight and also staff weight

staff

multidepartment_staff

department

A partial result

im not sure if im doing this right but i tried it like this

but i received error

Table ‘d’ from one of the SELECTs cannot be used in field list

Advertisement

Answer

Without looking too closely, perhaps you’re after something like this (although, at a glance, I don’t really see why the department table is required here – nor indeed why there are two separate tables for staff)

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement