我最近添加了一个排序字段,现在我想对结果进行排序。我可以用 PHP 或直接在数据库上做。所以我尝试了第二个:
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
我尝试使用内部连接将完整的表与结果集匹配。但我无法让它工作(#1248 - Every derived table must have its own alias
)。我尝试使用别名,但仍然有问题。也许我不应该使用内部联接IN()
来代替使用。