【发布时间】:2017-04-25 19:00:59
【问题描述】:
我有一个名为 table's 的人。此表的列“outsourcedData”包含以下 xml 作为字符串:
<person>
<educations total="2">
<education>
<school-name>Delhi University</school-name>
<degree>Master of Science (MSc)</degree>
<field-of-study>Banking and Financial Support Services</field-of-study>
<start-date>
<year>2009</year>
</start-date>
<end-date>
<year>2013</year>
</end-date>
</education>
<education>
<school-name>American University</school-name>
<degree>Bachelor of Arts (BA)</degree>
<field-of-study>Business Administration and Management, General</field-of-study>
</education>
</educations>
</person>
此表中有许多类似的行可用。有什么办法可以加载这些数据解析并插入到教育表中。
There are lots of row I am having in my database. But now I want to import this data into new table Education which I newly created in database corresponding fields with xml.(SchoolName,degree......).
在 Mysql 数据库中,迁移此数据库的最佳方法是什么。
我被困在这个地方。请帮忙。帮助
create table person (id int,outersource varchar(1024));
insert into person values(1,'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><person><educations total="2"><education><school-name>Delhi University</school-name><degree>Master of Science (MSc)</degree><field-of-study>Banking and Financial Support Services</field-of-study><start-date><year>2009</year></start-date><end-date><year>2013</year></end-date></education><education><school-name>American University</school-name><degree>Bachelor of Arts (BA)</degree><field-of-study>Business Administration and Management, General</field-of-study></education></educations></person>');
create table education( schoolName varchar(255), degree varchar(255),start_year datetime, end_year datetime);
任何我们可以做到这一点的存储过程?
【问题讨论】:
-
只需在 JOIN 中进行更新,但很难知道您的问题是什么。
-
我的一张表有数据。该表包含 XML 字符串以及我在此处显示的内容。我可以在这个表上触发选择查询。现在我创建了一个新表 Education。在这个新表中,我想迁移我以前的 XML 数据,这些数据在该表中以 XML 字符串形式提供
-
在education表中新建一列然后
INSERT INTO education(newColumn) SELECT oldColumn FROM MyOneTable -
我不想将该 xml 字符串重复到 Education 表中。我想解析那个 Xml 字符串,然后插入到 Education 表中。教育表中的一对一值。
-
希望你现在能得到我的确切问题