Re: [GENERAL] Insert data in two columns same table

2016-03-19 Thread Vick Khera
On Wed, Mar 16, 2016 at 9:34 PM, drum.lu...@gmail.com wrote: > The problem is that I need to do that at the same time, because of a > constraint: > > Mark your constraint as deferrable, and then defer the constraints within your transaction.

Re: [GENERAL] Insert data in two columns same table

2016-03-19 Thread Andreas Kretschmer
> "drum.lu...@gmail.com" hat am 17. März 2016 um 02:34 > geschrieben: > > > I'm trying to insert data from TABLE A to TABLE B. > > 1 - Select billable_id from dm.billable > 2 - Select mobiuser_id from ja_mobiusers > 3 - Insert the billable_id and the mobiuser_id to the dm.billables_links > ta

Re: [GENERAL] Insert data in two columns same table

2016-03-19 Thread Andreas Kretschmer
> > > 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

Re: [GENERAL] Insert data in two columns same table

2016-03-19 Thread Andreas Kretschmer
> > > Hi Andreas! > > Well... > > There are two tables that I need to get data from(dm.billables / > public.ja_mobiusers), and a third table (dm.billables_links) that I need to > insert data from those two tables. lets start from here. you have 2 tables: test=*# select * from source1; i ---

Re: [GENERAL] Insert data in two columns same table

2016-03-19 Thread David G. Johnston
On Wed, Mar 16, 2016 at 6:49 PM, Andreas Kretschmer wrote: > > > > "drum.lu...@gmail.com" hat am 17. März 2016 um > 02:34 > > geschrieben: > > > > > > I'm trying to insert data from TABLE A to TABLE B. > > > > 1 - Select billable_id from dm.billable > > 2 - Select mobiuser_id from ja_mobiusers >

Re: [GENERAL] Insert data in two columns same table

2016-03-19 Thread drum.lu...@gmail.com
> > > > I see a lot of other problems: you have 3 independet tables. Your 2 queries > (selects) returns 2 independet results, you can't use that for insert into > the > 3rd table. And i think, you are looking for an update, not insert. So you > have > to define how your tables are linked together (

Re: [GENERAL] Insert data in two columns same table

2016-03-19 Thread drum.lu...@gmail.com
On 18 March 2016 at 03:23, Adrian Klaver wrote: > On 03/16/2016 07:07 PM, drum.lu...@gmail.com wrote: > >> >> >> >> >> I see a lot of other problems: you have 3 independet tables. Your 2 >> queries >> (selects) returns 2 independet results, you can't use that for >> insert into th

Re: [GENERAL] Insert data in two columns same table

2016-03-18 Thread John R Pierce
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 'Da

[GENERAL] Insert data in two columns same table

2016-03-18 Thread drum.lu...@gmail.com
I'm trying to insert data from TABLE A to TABLE B. 1 - Select billable_id from dm.billable 2 - Select mobiuser_id from ja_mobiusers 3 - Insert the billable_id and the mobiuser_id to the dm.billables_links table. *FYI -* It has to be in the same transaction because the mobiuser_id must go to the

Re: [GENERAL] Insert data in two columns same table

2016-03-18 Thread Adrian Klaver
On 03/16/2016 07:07 PM, drum.lu...@gmail.com wrote: I see a lot of other problems: you have 3 independet tables. Your 2 queries (selects) returns 2 independet results, you can't use that for insert into the 3rd table. And i think, you are looking for an update, not insert.