[SQL] Re: [GENERAL] foreign key to multiple tables depending on another column's value

2013-05-29 Thread Rodrigo Rosenfeld Rosas
Em 29-05-2013 12:51, Vick Khera escreveu: On Wed, May 29, 2013 at 9:58 AM, Rodrigo Rosenfeld Rosas mailto:rr.ro...@gmail.com>> wrote: I know I could use a trigger, or some check constraint maybe, to ensure the field exists upon insert (or update), but I can't ensure t

[SQL] foreign key to multiple tables depending on another column's value

2013-05-29 Thread Rodrigo Rosenfeld Rosas
Sorry, I wasn't sure what list I should be sending this question to... I have a multi-tenant-like application. We have a fields tree that we call a template, with something like this: fields(id, parent_id, name) And several other related tables. Since we started to support multiple templates

Re: [SQL] ORDER BY COLUMN_A, (COLUMN_B or COLUMN_C), COLUMN_D

2012-09-12 Thread Rodrigo Rosenfeld Rosas
Em 12-09-2012 19:34, Gavin Flower escreveu: On 13/09/12 09:44, Rodrigo Rosenfeld Rosas wrote: This is my first message in this list :) I need to be able to sort a query by column A, then B or C (which one is smaller, both are of the same type and table but on different left joins) and then by

Re: [SQL] ORDER BY COLUMN_A, (COLUMN_B or COLUMN_C), COLUMN_D

2012-09-12 Thread Rodrigo Rosenfeld Rosas
Sep 12, 2012 at 2:44 PM, Rodrigo Rosenfeld Rosas mailto:rr.ro...@gmail.com>> wrote: This is my first message in this list :) I need to be able to sort a query by column A, then B or C (which one is smaller, both are of the same type and table but on different left joins) an

[SQL] ORDER BY COLUMN_A, (COLUMN_B or COLUMN_C), COLUMN_D

2012-09-12 Thread Rodrigo Rosenfeld Rosas
This is my first message in this list :) I need to be able to sort a query by column A, then B or C (which one is smaller, both are of the same type and table but on different left joins) and then by D. How can I do that? Thanks in advance, Rodrigo. -- Sent via pgsql-sql mailing list (pgsql-s