我想要创建单独的行,在每个单元格中包含一个单词。这些单词目前存储在一列中的多个单元格中。
下面是我的格式
A
玩,游戏,在线,免费,有趣
好玩,玩,街机,在线
比赛,有趣,玩
将被转换成下面
B
玩
游戏
在线
免费
有趣的
拱廊
赛程
有趣的
请注意,如果已经为一个单词创建了一行,则不应重复。
发布于 2011-12-27 19:47:23
这通常是在SQL以外的其他东西中更好地实现的,比如java。
伪代码可以是:
List<String> names = jdbcTemplate.query("select A from your_table", new RowMapper() {
public Object mapRow(ResultSet resultSet, int i) throws SQLException {
return resultSet.getString(1);
}
});
for (String name : names) {
String[] strings = name.split("[\\w,]");
for (int i = 0; i < strings.length; i++) {
String string = strings[i];
jdbcTemplate.update("insert ignore into new_table (B) values (?)", string);
}
}https://stackoverflow.com/questions/8648115
复制相似问题