我有大量查询,例如:
INSERT INTO `test` (`test_id`, `test_title`, `test_pic`, `test_date`, `test_date`, value) VALUES
(10, 'Dance0', 'NoPhoto.jpg', '1900-01-01 00:00:00', 0),
(11, 'Dance1', 'NoPhoto.jpg', '1900-01-01 00:00:00', 0),
(12, 'Dance2', 'NoPhoto.jpg', '1900-01-01 00:00:00', 0),
(13, 'Dance3', 'NoPhoto.jpg', '1900-01-01 00:00:00', 0)
我想拆分并添加 id,并关闭查询的括号 (),):
(10, 'Dance0', 'NoPhoto.jpg'),
(10, '1900-01-01 00:00:00', 0),
(11, 'Dance1', 'NoPhoto.jpg'),
(11, '1900-01-01 00:00:00', 0),
(12, 'Dance2', 'NoPhoto.jpg'),
(12, '1900-01-01 00:00:00', 0),
(13, 'Dance', 'NoPhoto.jpg'),
(13, '1900-01-01 00:00:00', 0),
这怎么能做到呢?问题的示例/解决方案将非常感激
谢谢
最佳答案
最简单的方法是在加载数据后重组数据。为此:
select test_id, test_title, test_pic
from test
union all
select test_id, test_date, value
from test;
我非常不清楚为什么你想要这样做。原始数据的格式似乎正确。
编辑:
如果你想创建两个表:
create table table1 as
select test_id, test_title, test_pic
from test;
create table table2 as
select test_id, test_date, value
from test;
关于javascript - 将 SQL 行拆分为两行并正确构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55660664/