I recently added a sorting field and now I want to sort the result. I could do it in PHP or directly on the database. So I tried the second one:
SELECT *
FROM constructions
AS whole
INNER JOIN
(
SELECT DISTINCT construction
FROM data
AS results
WHERE product =2
AND application =1
AND requirement =1
)
ON whole.id = results
ORDER BY whole.sorting
I tried to use inner join to match the complete table with the result set. But I can’t get it working (#1248 - Every derived table must have its own alias). I tried to use the alias but something is still wrong. Perhaps I shouldn’t user inner join and use IN() instead.
2 obvious errors in the syntax: