使用select插入数据

时间:2013-12-10 13:55:06

标签: mysql

我正在尝试执行以下操作:

INSERT INTO job_additions (sor_no, sor_desc, invoice_no, qty, debit_credit)
VALUES
('CAR102008',(select sor_desc from sor_data where sor_no= CAR102008),'INV001002','2','d')

但是我在“字段列表”中收到未知列'sor_desc'的错误

是否可以插入从另一个表中选择的数据?

非常感谢,

约翰

1 个答案:

答案 0 :(得分:1)

试试这样:

insert into job_additions (sor_no, sor_desc, invoice_no, qty, debit_credit)
select 'CAR102008', sor_desc, 'INV001002','2','d'
from sor_data 
where sor_no= 'CAR102008'