[SQL] ordered by join? ranked aggregate? how to?

2009-09-14 Thread wstrzalka
What I need is to join 2 tables CREATE TABLE master( id INT4 ); CREATE TABLE slave ( master_id INT4, rank INT4, value TEXT); What I need is to make the query: SELECT m.id, array_agg(s.value) AS my_problematic_array FROM master AS m LEFT JOIN slave AS s ON (m.id = s.master_id)

Re: [SQL] CHECK constraint on multiple tables

2009-09-14 Thread Thomas Kellerer
Mario Splivalo wrote on 14.09.2009 16:20: Have you considered refactoring so there's only one table? Unfortunately I can't do that, due to the object-relational-mapper-wrapper-mambo-jumbo. You could still refactor that into one single table, then create two updateable views with the names th

Re: [SQL] CHECK constraint on multiple tables

2009-09-14 Thread Mario Splivalo
Tom Lane wrote: > Mario Splivalo writes: >> I have two tables, tableA and tableB: >> CREATE TABLE tableA (idA integer primary key, email character varying >> unique); >> CREATE TABLE tableB (idB integer primary key, email character varying >> unique); > >> Now, I want to create check constraint i

Re: [SQL] CHECK constraint on multiple tables

2009-09-14 Thread Tom Lane
Mario Splivalo writes: > I have two tables, tableA and tableB: > CREATE TABLE tableA (idA integer primary key, email character varying > unique); > CREATE TABLE tableB (idB integer primary key, email character varying > unique); > Now, I want to create check constraint in both tables that would >

Re: [SQL] CHECK constraint on multiple tables

2009-09-14 Thread Mario Splivalo
How would you do it, without creating third table? Mario Ries van Twisk wrote: > can't you solve it creating a reference between the tables? > > Ries > On Sep 14, 2009, at 8:24 AM, Mario Splivalo wrote: > >> I have two tables, tableA and tableB: >> >> CREATE TABLE tableA (idA integer pr

Re: [SQL] CHECK constraint on multiple tables

2009-09-14 Thread Ries van Twisk
can't you solve it creating a reference between the tables? Ries On Sep 14, 2009, at 8:24 AM, Mario Splivalo wrote: I have two tables, tableA and tableB: CREATE TABLE tableA (idA integer primary key, email character varying unique); CREATE TABLE tableB (idB integer primary key, email character

[SQL] CHECK constraint on multiple tables

2009-09-14 Thread Mario Splivalo
I have two tables, tableA and tableB: CREATE TABLE tableA (idA integer primary key, email character varying unique); CREATE TABLE tableB (idB integer primary key, email character varying unique); Now, I want to create check constraint in both tables that would disallow records to either table whe