由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - How to split a column into several rows?
相关主题
mysql mapping and insert questionperformance problem in Oracle Package
mySQL 问题 (转载)a simple question about insert
sql 请教MySQL 的一个问题求教
Access 里面两个 column不一样的table 能combine 到一起吗?Help on Sql server huge table performance
谁能帮我看看这个Insert语句要怎么改一下?Like 和 equal 啥区别?
SQL copy a table into a new table and add a new column这种insert怎么做
请问sql 有条件性的select columns[合集] 这种insert怎么做
SQL select one value column for each distinct value another (转载)want to import CSV file to mysql, so I have to create a table first?
相关话题的讨论汇总
话题: a1话题: b11话题: col2话题: a2话题: col1
进入Database版参与讨论
1 (共1页)
b******t
发帖数: 10
1
have a table
col1 col2
a1 b11,b12
a2 b21,b22
...
want to make a new table as
col1 col2
a1 b11
a1 b12
a2 b21
a2 b22
...
how to do this in MySQL?
thanks
s**********o
发帖数: 14359
2
倒出去,重新IMPORT进来,然后INSERT INTO TARGET TABLE
QUESTION WHAT IF DUPLICATE
col1 col2
a1 b11
a1 b11
a1 b11
a1 b12
a2 b21
a2 b22
y****w
发帖数: 3747
3
发包子吧,这个板上人们都腻歪做作业了。

【在 b******t 的大作中提到】
: have a table
: col1 col2
: a1 b11,b12
: a2 b21,b22
: ...
: want to make a new table as
: col1 col2
: a1 b11
: a1 b12
: a2 b21

b******t
发帖数: 10
4
导出去的话会弄,不倒不行?
b******t
发帖数: 10
5
好啊,包子什么价啊,我只有伪币0.8都给你,

【在 y****w 的大作中提到】
: 发包子吧,这个板上人们都腻歪做作业了。
s**********o
发帖数: 14359
6
不倒就是要搞字符串处理,然后INSERT
m*********2
发帖数: 178
7
pivot and unpivot
y*****g
发帖数: 677
8
My solution is only work for fixed number of values in the col2,
for simplicity, if there is only 2 values in col2,
the following works:
insert into combined select a.col1, substring_index(a.col2,',',1) from
mytest a union all select b.col1,substring_index(b.col2,',',-1) from mytest
b;
mysql> select * from newt order by col1;
+------+-------------------------------+
| col1 | substring_index(a.col2,',',1) |
+------+-------------------------------+
| a1 | b11 |
| a1 | b12 |
| a2 | b21 |
| a2 | b22 |
+------+-------------------------------+
4 rows in set (0.04 sec)
1 (共1页)
进入Database版参与讨论
相关主题
want to import CSV file to mysql, so I have to create a table first?谁能帮我看看这个Insert语句要怎么改一下?
How to handle inserting value to Identity column in sql server 2005SQL copy a table into a new table and add a new column
用SSIS EXPORT 到 EXCEL 2010 有2000个COLUMN,可能吗请问sql 有条件性的select columns
sql query helpSQL select one value column for each distinct value another (转载)
mysql mapping and insert questionperformance problem in Oracle Package
mySQL 问题 (转载)a simple question about insert
sql 请教MySQL 的一个问题求教
Access 里面两个 column不一样的table 能combine 到一起吗?Help on Sql server huge table performance
相关话题的讨论汇总
话题: a1话题: b11话题: col2话题: a2话题: col1