Re: Insert data in two columns same table

Поиск
Список
Период
Сортировка
От John R Pierce
Тема Re: Insert data in two columns same table
Дата
Msg-id 56EA1417.1020502@hogranch.com
обсуждение исходный текст
Ответ на Re: Insert data in two columns same table  ("drum.lucas@gmail.com" <drum.lucas@gmail.com>)
Ответы Re: Insert data in two columns same table  (Andreas Kretschmer <andreas@a-kretschmer.de>)
Список pgsql-general
On 3/16/2016 7:07 PM, drum.lucas@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

В списке pgsql-general по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Insert data in two columns same table
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Insert data in two columns same table