我正在尝试做这样的事情:
INSERT
INTO
my_test
(
name,
sirname,
Dept
)
VALUES
(('First Name'),(SELECT sirname, Dept FROM my_test_backup WHERE dept = 500));
我得到的错误是太多的值。
答案 0 :(得分:7)
如果要插入硬编码值,请将其作为选择的一部分。
insert into my_test
(name, sirname, dept)
(select 'First Name'
,sirname
,dept
from my_test_backup
where dept = 500)
答案 1 :(得分:2)
INSERT INTO my_test( name, sirname, Dept )
(SELECT 'First Name', sirname, Dept FROM my_test_backup WHERE dept = 500)
答案 2 :(得分:1)
我认为它应该是
INSERT INTO my_test ( name, sirname, Dept )
(SELECT FirstName, sirname, Dept FROM my_test_backup WHERE dept = 500);
答案 3 :(得分:1)
你可以试试这个
INSERT INTO my_test ( name, sirname, Dept )
(SELECT 'firstname' as name,sirname, Dept FROM my_test_backup WHERE dept = 500);
答案 4 :(得分:0)
INSERT INTO my_test
(name, sirname, Dept)
SELECT name, sirname, Dept
FROM my_test_backup
WHERE dept=500;