I have two tables. We'll call them table A and table B. They both have the column color_id. Is there any way I can tell MySQL to not add a row to table B if the color_id does not exist in table A?
Printable View
I have two tables. We'll call them table A and table B. They both have the column color_id. Is there any way I can tell MySQL to not add a row to table B if the color_id does not exist in table A?
something like
insert into B(color_id)
select A.color_id
from a
left join B
on a.color_id=b.color_id
where b.color_id is null