我在MySQL中为牙科练习创建了这个查询
SELECT Paz.Nome, Paz.Cognome
FROM Paziente AS Paz, Visita AS Vis
WHERE Vis.Paziente=Paz.CF AND MAX(Vis.Parcella)=Vis.Parcella
但不适用于错误1111.请帮帮我
答案 0 :(得分:1)
试试这个,我在连接中指定了第二个表,max语句需要采用子查询的形式:
SELECT
Paz.Nome,
Paz.Cognome
FROM Paziente AS Paz
LEFT JOIN Visita AS Vis ON Vis.Paziente=Paz.CF
WHERE (SELECT MAX(Parcella) FROM Visita)=Vis.Parcella;