Re: [SQL] Using case or if to return multiple rows

2007-07-12 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > it's possible with one big disadvantage. This query will do seq scan > both tables and it can be slow on big tables. No, it should be reasonably OK, because if the added condition doesn't involve the tables being scanned it'll be turned into a one-time

Re: [SQL] Using case or if to return multiple rows

2007-07-12 Thread Pavel Stehule
> > > select case when t3.date='' then > select * from table1 > else > select * from table 2 > from table3 t3 where t3.date='x' > > Problem is that I have to do it in Plain SQL. you problem is not quite clear. do you want to output al

Re: [SQL] Using case or if to return multiple rows

2007-07-12 Thread Ragnar
On fim, 2007-07-12 at 12:15 +0530, Ashish Karalkar wrote: > I want to select data from two diffrent table based on third tables > column > somthing like: > > > select case when t3.date='' then > select * from table1 > else > select * from table 2 >

Re: [SQL] Using case or if to return multiple rows

2007-07-12 Thread Pavel Stehule
Hello what is relation between t1 and t3 and t2 and t3? Which row from t3 specifies value? You cannot do it in plain SQL. SQL is well for set operations. You can use plpgsql and SRF function. -- table1 and table2 have to have same structure CREATE OR REPLACE FUNCTION output_tab(date) RETURNS

[SQL] Using case or if to return multiple rows

2007-07-11 Thread Ashish Karalkar
Hello all, I want to select data from two diffrent table based on third tables column somthing like: select case when t3.date='' then select * from table1 else select * from table 2 from table3 t3 where t3.date='x' Prob