这里有人帮助整理了这个非常有用的查询!
SELECT * FROM results r
INNER JOIN categories c on r.id = c.result_id
WHERE c.name in ('$purpose', '$prop_type', '$loan_type')
GROUP BY r.id
HAVING COUNT(c.c_id) = 3
LIMIT 50 OFFSET 0
哪个很好用!但是,当我尝试使用
SELECT * FROM results r
INNER JOIN categories c on r.id = c.result_id
WHERE c.name in ('$purpose', '$prop_type', '$loan_type')
ORDER BY r.usefulness DESC
GROUP BY r.id
HAVING COUNT(c.c_id) = 3
LIMIT 50 OFFSET 0
我收到语法错误。我在这里遗漏了一些明显的东西吗?
非常感谢!