我的 SQL 返回值如下。
enter code here
studentid studentname playid gamename grade prizes
--------- ------------ ----- ------------ ------ ---------
121 bob 1 game1 A 1 and 2
121 bob 2 game2 C 1 and 3
121 bob 3 game3 B 4 and 2
121 bob 4 game4 D 1 and 2
131 jack 3 gam3 A 1
131 jack 1 game1 A 2 and 3
我得到结果并迭代要显示的值。但在最后一列中需要将值显示为不同的格式。
Iterator<Search> iterator = products.iterator();
while(iterator.hasNext())
{
Search req = (Search)iterator.next();
req.getStudentid();
req.getStudentname();
req.getgameid();
req.getgamename();
req.getgrade();
req.getprizes() ;
}
显示格式是...
studentid studentname playid gamename grade prizes
---------- ----------- ------ -------- ------- ---------
121 bob 1 game1 A 1 and 2 and 3 and 4
121 bob 2 game2 C 1 and 2 and 3 and 4
121 bob 3 game3 B 1 and 2 and 3 and 4
121 bob 4 game4 D 1 and 2 and 3 and 4
131 jack 3 gam3 A 1 and 2 and 3
131 jack 1 game1 A 1 and 2 and 3
如何在第一行附加奖品 4 行值?如何在这里循环?请帮我。
编辑:我的 SQL 查询是:
SELECT stu.studentid, stu.studentname,g.playid,stu.gamename,g.grade,g.prizes
FROM student stu , game g
WHERE stu.studentid = g.studentid AND stu.year = g.year