我尝试进行该查询,但由于错误1241我无法使用NOT IN超过1列,并且我无法在NOT IN之前使用两个atribut。
SELECT * FROM futbol.puntos WHERE Equipo, Liga
NOT IN
(SELECT der.Equipo,der.Liga,der.Puntos
FROM (SELECT p.Equipo, p .Liga, p.Puntos,
IF(@prev_liga != p.Liga,
@rownum:= 1,
@rownum := @rownum + 1) rank,
@prev_liga:=p.Liga
FROM (SELECT Equipo, Liga, Puntos FROM puntosmitadliga GROUP BY Liga, Puntos, Equipo ORDER BY Liga, Puntos DESC) p,
(SELECT
@rownum:= NULL,
@prev_liga := 0) r) der WHERE der.rank <= 3 ORDER BY der.Liga, der.rank) GROUP BY Liga HAVING max(puntos);
我该如何解决?
答案 0 :(得分:0)
SELECT * FROM my_table;
+----------------+-------------+
| customerNumber | orderNumber |
+----------------+-------------+
| 40 | 1 |
| 30 | 2 |
| 40 | 3 |
| 20 | 4 |
| 30 | 5 |
+----------------+-------------+
SELECT *
FROM my_table
WHERE (customernumber,ordernumber) NOT IN ((40,1),(30,3));
+----------------+-------------+
| customerNumber | orderNumber |
+----------------+-------------+
| 30 | 2 |
| 40 | 3 |
| 20 | 4 |
| 30 | 5 |
+----------------+-------------+
4 rows in set (0.07 sec)
mysql>