the scenario is as follows:
I have an
supplier table. The
supplier_id. I want to insert into
supplier_company does not exist in the
supplier table, first insert into
supplier then use the new
invoice, else use the
supplier_id of the matching
I've managed to get here:
insert into supplier (supplier_company) select ('Company Name') where not exists (select 1 from supplier where supplier_company='Company Name');
insert into invoice (invoice_number, supplier_id) values (xxx, (select supplier_id from supplier where supplier_company = 'Company Name')
but I was wondering if there's a cleaner, clearer way to express this in one expression.
Thank you for your time.