Reputation: 21
EMAIL EML_GRP
------- -----
[email protected] 1,2,3
[email protected] 1,4,5
This is the table structure. How do I parse the values in the EML_GRP field? I am using mySQL.
Upvotes: 0
Views: 73
Reputation: 114757
Assuming (1) you use Java language and (2) you already submitted a query and read the values from a ResultSet, then you might have two Strings per record
String email = "[email protected]"; // just to demonstrate
String eml_grp = "1,2,3";
To get the numbers out of eml_grp, you can use the String.split method:
String[] numbers = eml_grp.split(",");
Upvotes: 0
Reputation: 14102
Never store comma separated lists in database.
Read about normalization:
http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
http://mysqldump.azundris.com/archives/20-Nermalisation.html
http://www.keithjbrown.co.uk/vworks/mysql/
Upvotes: 1