[英]SQL : I am only getting one row returned per user
我需要為每個用戶返回游戲“抽認卡”的所有行。
目前我只為每個用戶返回一行。
SELECT
s.name as Escuela,
sc.class_description as Clase,
u.level as "Nivel Del Alumno",
CONCAT(u.firstname," ",u.lastname) as Nombre,
stats.game_type as "Tipo de Juego",
MIN(stats.time) as "Tiempo en Segundos",
SEC_TO_TIME(stats.time) as "Tiempo en Formato"
FROM
game_statistics stats
INNER JOIN
users1 u ON stats.user_id = u.id
INNER JOIN
school_classes sc ON u.class_id = sc.id
INNER JOIN
schools s ON s.id = sc.school_id
WHERE
stats.game_type LIKE 'flashcards'
GROUP BY
s.name, sc.class_description,
u.level, Nombre, stats.game_type
ORDER BY
s.name, sc.class_description,
u.level, stats.game_type, stats.time
使用以下查詢。 您必須包含%
通配符以獲取包含文本flashcard
所有行。 無論何時在查詢中使用LIKE
運算符,都應該使用通配符,否則使用LIKE
的目的就會失敗。
SELECT
s.name AS Escuela
,sc.class_description AS Clase
,u.level AS "Nivel Del Alumno"
,CONCAT(u.firstname, " ", u.lastname) AS Nombre
,stats.game_type AS "Tipo de Juego"
,MIN(stats.TIME) AS "Tiempo en Segundos"
,SEC_TO_TIME(stats.TIME) AS "Tiempo en Formato"
FROM game_statistics stats
INNER JOIN users1 u
ON stats.user_id = u.id
INNER JOIN school_classes sc
ON u.class_id = sc.id
INNER JOIN schools s
ON s.id = sc.school_id
WHERE stats.game_type LIKE '%flashcards%'
GROUP BY s.name
,sc.class_description
,u.level
,Nombre
,stats.game_type
ORDER BY s.name, sc.class_description, u.level, stats.game_type, stats.TIME
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.