开发者

How to parse values from database

开发者 https://www.devze.com 2023-01-06 01:08 出处:网络
EMAILEML_GRP ------------ HELL0@GMAIL.COM1,2,3 HAI@GAMIL.COM1,4,5 开发者_如何学JAVA This is the table structure. How do I parse the values in the EML_GRP field? I am using mySQL.Never store comma s
    EMAIL                EML_GRP   
  -------                 -----      

HELL0@GMAIL.COM            1,2,3

HAI@GAMIL.COM              1,4,5
开发者_如何学JAVA

This is the table structure. How do I parse the values in the EML_GRP field? I am using mySQL.


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/


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 = "hello@gmail.com";  // 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(",");
0

精彩评论

暂无评论...
验证码 换一张
取 消