SQL = "SELECT player.Player, Count(player.Player) AS TotalGames FROM player GROUP BY player.Player HAVING player LIKE '%playboys%' ORDER BY Count(player.Player) DESC;"
mener det skal laves sådan. "having" bruges ikke her.
SQL = "SELECT player.Player, Count(player.Player) AS TotalGames FROM player WHERE player LIKE '%playboys%' GROUP BY player.Player ORDER BY Count(player.Player) DESC;"
er det ikke lidt smag og behag i dette tilfælde. Med WHERE kan du checke alle felter, men med HAVING er det kun det/de felt/er der i med i GROUP BY - (så vidt jeg husker).
jeg ville tror at når man bruger having, kører den første GROUP BY. Dernæst kigger den på HAVING delen og frasorterer igen. Det kan da godt være at databasen har en intilligent optimizer, der kan gøre det i et huk.
SQL = "SELECT player.Player, Count(player.Player) AS TotalGames FROM player WHERE player<>'cheater-playboys' GROUP BY player.Player ORDER BY Count(player.Player) DESC;"
Ok, jammen så tak. Men sql'en virkede ikke som planlagt.
SQL = "SELECT player.Player, Count(player.Player) AS TotalGames FROM player WHERE player<>'cheater-playboys' GROUP BY player.Player ORDER BY Count(player.Player) DESC;"
Viser godtnok alle undtagen Cheater-playboys, men hvordan sætter jeg så WHERE player LIKE '%playboys%' ind i sætningen ?
det behøver du heller ikke, det var bare din formulering i dit spm. der gjorde at vi svarede på den måde. Brug bare:
SQL = "SELECT player.Player, Count(player.Player) AS TotalGames FROM player WHERE player='playboys' GROUP BY player.Player ORDER BY Count(player.Player) DESC;"
SQL = "SELECT player.Player, Count(player.Player) AS TotalGames FROM player WHERE player<>'cheater-playboys' AND player LIKE '%playboys%' GROUP BY player.Player ORDER BY Count(player.Player) DESC;"
Hvis du selv har lyst til at lære det bør du kigge på:
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.