从多个表中选择mysql Java
如何使用给定的剧院城市变量向Arraylist插入不同的电影标题
例如,我希望在Arraylist中填充showtimes表中链接到其城市为洛杉矶的剧院id的所有电影标题
showtimes表格
id movieId theaterId
1 1 1
2 1 1
3 1 2
4 1 2
5 2 2
6 2 2
7 1 3
8 4 1
剧院表
id city
1 LA
2 NY
2 NJ
电影表格
id title
1 avengers
2 matrix
3 lotr
4 inception
结果Arraylist应填充为:复仇者和盗梦空间
因为laid是1,它在showtimes表中导致movieId
1,1,4
这些{
# 1 楼答案
您可以通过JDBC在数据库中执行此操作,例如
然后迭代结果集并将其添加到
ArrayList