insert into sycle(name,password) values(select name from name_table,'name');
插入到sycle(名称、密码)值(从name_table中选择名称,“name”);
i am having problem in inserting additional value with the parameter received from the select subquery.
我在向select子查询接收的参数插入附加值时遇到了问题。
it can be done in two query, but i want to kn ow if it can be done in a single query.
它可以在两个查询中完成,但是如果可以在单个查询中完成,我想要kn ow。
4 个解决方案
#1
2
insert into sycle(name,password)
select name, password from name_table
or if password is a variable:
或者如果密码是一个变量:
insert into sycle(name,password)
select name, @password from name_table
if password is 'name' then:
如果密码是“name”,那么:
insert into sycle(name,password)
select name, 'name' from name_table
#2
1
Try:
试一试:
INSERT INTO sycle(name,password) VALUES (SELECT name, 'name' FROM name_table);
although this will take only single name from name_table. If you want to get a whole bunch of values do:
尽管这只需要name_table中的一个名称。如果你想要得到一系列的值
INSERT INTO sycle(name,password) SELECT name, 'name' FROM name_table;
#3
1
This is what you're looking for:
这就是你要找的:
INSERT INTO sycle
(
name
,password
)
SELECT name
,NULL -- password
FROM name_table
#4
0
give this a try
尝试一下这个
insert into sycle select name,'name' from name_table
从name_table中插入sycle选择名称“name”。
#1
2
insert into sycle(name,password)
select name, password from name_table
or if password is a variable:
或者如果密码是一个变量:
insert into sycle(name,password)
select name, @password from name_table
if password is 'name' then:
如果密码是“name”,那么:
insert into sycle(name,password)
select name, 'name' from name_table
#2
1
Try:
试一试:
INSERT INTO sycle(name,password) VALUES (SELECT name, 'name' FROM name_table);
although this will take only single name from name_table. If you want to get a whole bunch of values do:
尽管这只需要name_table中的一个名称。如果你想要得到一系列的值
INSERT INTO sycle(name,password) SELECT name, 'name' FROM name_table;
#3
1
This is what you're looking for:
这就是你要找的:
INSERT INTO sycle
(
name
,password
)
SELECT name
,NULL -- password
FROM name_table
#4
0
give this a try
尝试一下这个
insert into sycle select name,'name' from name_table
从name_table中插入sycle选择名称“name”。