I'm making program for teachers with Java and mysql , so I've many tables in mysql such as students table which contains student name and number and ID .. etc , also another table that called groups , It contains group name , place and students .. etc. So , the problem is , in Groups table I'll add IDs of students in one row just like the image bellow beside the name of group , how can I take this IDs from mysql in this form and separate them automatically in program by java to search in the students table about the information of them .
image : https://i.stack.imgur.com/NFQ6t.jpg
try {
Class.forName("java.sql.Driver");
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/teacherassistant?allowMultiQueries=true","root","1234");
Statement st = (Statement) con.createStatement();
String query = "select * from Groups;";
ResultSet rs = st.executeQuery(query);
while(rs.next()){
String name = rs.getString("Name");
String StudentIDs= rs.getString("Students");
String Center = rs.getString("Center");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this,"Error");
}