On 3/16/2016 7:07 PM, drum.lu...@gmail.com wrote:
*1 -* select the billable_id: (SELECT1)
SELECT billable_id FROM junk.wm_260_billables2 WHERE info ilike '%Alisha%'
*2 -* select the mobiuser_id: (SELECT2)
SELECT id FROM public.ja_mobiusers WHERE name_first LIKE 'Alisha%' AND
name_last LIKE 'Dadryl%'
*3 -* Insert those two data into the dm.billables_links table (EXAMPLE):
INSERT INTO dm.billables_links (billable_id, mobiuser_id) VALUES
(SELECT1, SELECT2);
assuming those two queries 1 and 2 return multiple rows, which rows of
junk.wm_260_billables2 match up with what rows of public.ja_mobiusers ?
your schema is very poorly defined. I think you need to take a class in
relational database design and usage, or read a good book on it at least..
the *CORRECT* SOLUTION WOULD BE MORE LIKE
INSERT INTO dm.billables_links (billable_id, mobiuser_id) SELECT
b.billable_id, m.id from billables b inner join ja_mobiusers m on
b.billable_id = ... where ......
I left ... in because your code fragments are referencing fields that
aren't even IN your tables, and your tables don't have sane references.
--
john r pierce, recycling bits in santa cruz