0

This question is an exact duplicate of:

I wanna add some data into two columns in a table.

Would be something like:

INSERT INTO dm.billables_links (billable_id) VALUES ((SELECT billable_id FROM junk.wm_260_billables2 WHERE info ilike '%Ali%')),

INSERT INTO dm.billables_links (mobiuser_id) VALUES ((SELECT id FROM public.ja_mobiusers WHERE name_first LIKE 'Ali%' AND name_last LIKE 'Daon%'))

Question:

Note that the "billable_id" selected on the first INSERT must be related to the "mobiuser_id" selected on the second INSERT.

How can I do such a thing?

Table dm.billables.links columns:

billable_id, mobiuser_id

SELECT id FROM public.ja_mobiusers WHERE name_first LIKE 'Ali%' AND name_last LIKE 'Daon%'

950898

SELECT billable_id FROM junk.wm_260_billables2 WHERE info ilike '%Ali%'

13270372

marked as duplicate by Erwin Brandstetter postgresql Mar 17 '16 at 2:01

This question was marked as an exact duplicate of an existing question.

1

Fast and dirty:

 INSERT INTO dm.billables_links (billable_id,mobiuser_id) VALUES (
    (SELECT billable_id FROM dm.billables WHERE account_id = 32152 
    AND billable_id IN (select billable_id from junk.billable_id),
    (SELECT id FROM public.ja_mobiusers WHERE name_first LIKE 'Alisha%'));

or a JOIN, if an relation between "billable_id"(junk.billable_id) and "id"(public.ja_mobiusers) exists.