我想在限制100之内选择NULL值.左联接应使输出限制为100,并且在其中我要计算所有NULL值.我的子查询似乎无法正常工作.有什么想法我做错了吗?提前致谢!
我用SUM()尝试了一些东西,但是那也行不通
SELECT SUM(echonest.id IS NULL) FROM (SELECT *
FROM tracks,echonest
left JOIN echonest ON tracks.id = echonest.id
LIMIT 100)
SELECT *
FROM tracks AS t
LEFT JOIN echonest AS e ON t.id = e.id
LIMIT 100 IN
(SELECT COUNT(e.id)
FROM e
WHERE e.id IS NULL)
预期的输出应计入LIMIT 100以内的所有NULL值.
最佳答案
我想这就是你想要的
原文链接:https://www.f2er.com/mysql/531941.htmlSELECT COUNT(*) AS tot_nuls
FROM
(
SELECT E.id AS eid
FROM tracks T
LEFT JOIN echonest E ON T.id = E.id
LIMIT 100
) T
WHERE eid IS NULL
但是,如注释中多次指定的那样,您应注意,没有ORDER BY子句的LIMIT子句将返回不确定的(又名随机的)结果.