[SQL] conditional query?

2003-10-31 Thread Frank Morton
I have a table called a "profile" that has company addresses as well as individual contact information. Simpifying: id (the primary key) parentId (any profile can have a parent ie, contact parent is a company) address (for this example, will just have one piece of the address) useParentAddress If "

Re: [SQL] conditional query?

2003-10-31 Thread Achilleus Mantzios
Why dont you try a combination of CASE WHEN ... THEN ... ELSE ... END construct along with a LEFT OUTER join (in case parentId is null). Not sure how "portable" the above will be. O kyrios Frank Morton egrapse stis Oct 31, 2003 : > I have a table called a "profile" that has company addresses as

Re: [SQL] conditional query?

2003-10-31 Thread mlunnon @ RWA
Try something like SELECT p2.* FROM profile p1, profile p2 WHERE ( p1.id =1 AND useParenAddres = 'N' AND p2.id = p1.id ) OR ( p1.id =1 AND useParenAddres = 'Y' AND p2.id = p1.parentId) Obviously this won't work if you have more than one level of parent hood, i.e. it would pick up a grand

[SQL] selecting problems

2003-10-31 Thread Shaun Watts
What I am trying to do is select all the rows out of the categories table (see below) and select the sum of j_amount out of the judgment table. Right now it is only returning the categories that are in the judgment table. I want it to return those fields with the amounts out of the judgment tabl

Re: [SQL] selecting problems

2003-10-31 Thread Tomasz Myrta
Dnia 2003-10-31 20:19, Użytkownik Shaun Watts napisał: What I am trying to do is select all the rows out of the categories table (see below) and select the sum of j_amount out of the judgment table. Right now it is only returning the categories that are in the judgment table. I want it to return

Re: 7.4 and 7.3.5 showstopper (was: Re: [SQL] Bug in Rule+Foreing

2003-10-31 Thread Michele Bendazzoli
On Thu, 2003-10-30 at 20:13, Jan Wieck wrote: > Thanks for reporting, Michele. Thank to you! The speed and level of your responses exceeds every my more rose-colored expectation ;-) > In the meantime, you might want to use a > BEFORE INSERT trigger in PL/pgSQL that tries to UPDATE the row and i