0

table1 から table2 にデータを挿入し、自分のデータを 1 つの (同じ) クエリで table2 に挿入したいのですが、うまくいきません。これは私のクエリです

$query='insert into table2(id,name) values("001",select first_name from table1 where table1.id="001")';

私の質問のどこが間違っているのか誰か教えてください。とても喜んでいます。ありがとう。

4

3 に答える 3

2
insert into table2 (id, name) 
select '001', first_name 
from table1 
where id = '001'

またはid、それが001

insert into table2 (id, name) 
select id, first_name 
from table1 
where id = '001'
于 2013-07-09T15:08:09.143 に答える
1
insert into table2 (id, name)
    select id, first_name from table1 where table1.id = '001';

^ なぜハードコードするのselect '001'ですか?

于 2013-07-09T15:11:20.147 に答える
1
insert into table2(id,name) 
select "001",first_name from table1 where table1.id="001"
于 2013-07-09T15:08:40.167 に答える