你好我收到一个大的sql,用9k行导入我的数据库。问题是结构并不完全相同。
表格的标题是:
Name,Bday,Email,Phone
我收到了这样的
INSERT INTO `Persons` (`Firstname`, `Lastname`, `Bday`, `Email`, `Phone`) VALUES
('DRAGHICI', 'CLAUDIA', '1963-03-06', '', '0730010099'),
('CIMPEANU', 'ADRIAN GEORGE', '1975-03-06', '', '0747137312'),
('SIRBU', 'CRISTINA', '1985-05-17', '', '0726498751'),
('GHITA', 'DORU AURELIAN', '1962-04-20', '', '0722628325'),
('PALL', 'PETRISOR', '1980-06-24', '', '0745524485'),
('ZMARAND', 'MIHAELA', '1983-10-13', '', '23365646'),
('CHIRIAC', 'PETRE', '1948-04-26', '', '0745789651'),
('ZABAD', 'OMRAN MOHSEN', '1986-06-14', '', '0723368085'),
('TARA', 'SERGIU', '1974-12-01', '', '0722457299'),
('DRACULET', 'CLAUDIA OLIMPIA', '1978-01-22', '', '0745617755'),
('CINDEA', 'PETRISOR', '1970-01-17', '', '0351404534'),
('SAVESCU', 'ADRIANA MADALINA', '1980-09-12', 'madalina_savescu@yahoo.com', '0740699853'),
('POPA', 'SIMINA CLAUDIA', '1980-03-24', '', '0727 346126'),
('GHEORGHE', 'CONSTANTIN', '1986-02-04', '', '0760 244 833'),
('GEORGESCU', 'MARIETA', '1959-08-14', '', '0351422999'),
('SARBU', 'IULIAN', '1947-06-22', '', '0726565154'),
('CALAFETEANU', 'EMIL', '1954-03-20', '', '0745481772'),
('SURPATEANU', 'GEORGETA', '1952-01-26', '', '0743331284'),
('LIMBAN', 'DELIA MIHAELA', '1987-07-15', '', '222356'),
('MARCIU', 'ION', '1944-05-13', '', '0351407891'),
我需要将firstname lastname
合并到列name
答案 0 :(得分:1)
只需执行@ganesh_devlekar建议的内容,但在上次查询中进行此更改:
insert into OriginalTable (Name,Bday,Email,Phone)
select CONCAT(FNamem,' ',LName),Bday,Email,Phone
from TempTable
答案 1 :(得分:0)
创建其他表
create table TempTable(FName varchar(100),
LName varchar(100),Bday datetime,Email varchar(30),Phone int)
然后插入这些值
insert into TempTable(FNamem,LName,Bday,Email,Phone)
-- 9 k rows
然后做这样的事情:
insert into OriginalTable (Name,Bday,Email,Phone)
select FNamem,LName,Bday,Email,Phone
from TempTable