Use SELECT, which returns nothing if FK does not exist.
INSERT INTO furniture (model, type)
select 'modelA', 'chair'
where exists (select *
from model
where model.model = 'modelA');
You did not tell us what is called a reference table. I suggested that this modelis - you need to configure this for real names.
source
share