我需要循环通过表组织,并在用户表中插入新记录
Select Code,Organisationid from organisation
INSERT INTO User(userlogin,Organisationid,emailaddress,username,userpassword)
VALUES('AGT'+ Code, organisationid,'test@gmail.com','User'+ Code,'123')
我需要动态地将Organisationid和Code传递给user表,以循环并在User中插入新记录。
发布于 2018-05-31 17:03:10
只需使用INSERT INTO ... SELECT
即可
INSERT INTO User (userlogin, Organisationid, emailaddress, username, userpassword)
SELECT 'AGT' + Code, organisationid, 'test@gmail.com', 'User' + Code, '123'
FROM organisation;
https://stackoverflow.com/questions/50620455
复制相似问题