2013-03-27 129 views
-2

我有這些表:SUM與加入3個表

球員: IDHrace(INT) 名稱(VARCHAR)

Ucast_Zapas: ID_Hrace_zapas(INT) 門(INT)

比賽: ID_zapas(INT) kategorie_zapas(INT)

範疇: IDkategorie(在T)

我的代碼:

SELECT Jmeno, COUNT(Ucast) 
FROM Hraci 
INNER JOIN Ucast_Zapas ON Ucast_Zapas.ID_Hrace_zapas=Hraci.IDHrace 
INNER JOIN Zapas ON Zapas.ID_zapas=Ucast_Zapas.ID_Hrace_zapas 
INNER JOIN Kategorie ON Kategorie.IDkategorie=Zapas.Kategorie_zapas 
WHERE (Ucast=1)AND (Kategorie_zapas=1) 
GROUP BY Jmeno; 

,但它不是一個工作:/

+0

會發生什麼?是否有錯誤或僅返回數據? – GrandMasterFlush 2013-03-27 12:21:32

+0

什麼是你所得到的錯誤? – Aushin 2013-03-27 12:22:39

+0

沒有返回的數據...... – koky 2013-03-27 12:22:41

回答

0

所以你WHERE條款是錯誤的:

WHERE Hraci.IDHrace = 1 
+0

代碼:SELECT名稱,COUNT(參與)FROM Hraci ON INNER JOIN Ucast_Zapas Ucast_Zapas.ID_Hrace_zapas = Hraci.IDHrace ON INNER JOIN比賽Zapas.ID_zapas = Ucast_Zapas.ID_zapasu_ucast INNER JOIN類別ON = Kategorie.IDkategorie Zapas.Kategorie_zapas WHERE(參與= 1)AND(ID_zapasu_ucast = 10)和(Zapas.Kategorie_zapas = 2) 組按名稱; – koky 2013-03-27 12:50:47

+0

樣品:http://postimg.org/image/jhbwoujdv/ – koky 2013-03-27 13:02:51