khawla belgacem khawla belgacem - 7 months ago 10
SQL Question

insert records into table where one filed is from another table

i want to insert records into table "Cours_Change" but one filed is from other table "Devise";
I have selected the liste of Devises and its id will also be inserted into table "Cours_Change"

insert into Cours_Change (DAT_JOUR_CCHN,mont_caba_cchn,mont_cabc_cchn,mont_cvba_cchn,mont_cvbc_cchn,cod_etat_cchn,cod_dev_dev, matricule_emp)
values ('01/05/2016',2.1,2.1,2.1,2.1,'V', select d.cod_dev_dev from table Devise d where d.lib_sigl_dev='AUS', 'emp_2' );


This picture may be let you understand what i want to do

enter image description here

can you help me please

Answer

Try this:

insert into Cours_Change (DAT_JOUR_CCHN,mont_caba_cchn,mont_cabc_cchn,mont_cvba_cchn,mont_cvbc_cchn,cod_etat_cchn,cod_dev_dev, matricule_emp) 
select '01/05/2016',2.1,2.1,2.1,2.1,'V', d.cod_dev_dev, 'emp_2' 
from Devise d where d.lib_sigl_dev='AUS'
Comments