我设法编写了下面的查询,它几乎可以工作,问题是任何空值都被IFNULL(likes.num, 0)
结果表末尾的 get 清零。
SELECT t.*, IFNULL(likes.num, 0)
FROM `textagname` as t
LEFT JOIN likes
ON t.tex = likes.tex
ORDER BY num DESC
有没有另一种方法来编写这个查询,而不是这样:
SELECT *
FROM (
SELECT t.*, IFNULL(likes.num, 0)
FROM `textagname` as t
LEFT JOIN likes
ON t.tex = likes.tex
)
ORDER BY d.num DESC
最好是一种不会使其花费更长的时间的方法。