Re: conditional FROM

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: conditional FROM
Дата
Msg-id 20111210161725.GA15506@tux
обсуждение исходный текст
Ответ на conditional FROM  (Richard Klingler <richard@klingler.net>)
Список pgsql-sql
Richard Klingler <richard@klingler.net> wrote:

> Good day...
> 
> I'm trying to build a query for PGSQL 9.1 where a table has two 
> references with only one being used depending of the type of entry..
> 
> For example, the table has following simplified structure:
> 
>     portid        primary key
>     port2node    index to table node
>     port2card    index to table card
> 
> So how can I do a conditional FROM clause in the query depending on the 
> column port2node and port2card?
> If port2card is Null or 0 I don't want it in the FROM clause as the 
> query will return unneccessary duplicate
> row...the same goes for port2node being Null or 0...

I think, you can't do that, you have to build your query and execute
that string. You should use a function to do that.



Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°


В списке pgsql-sql по дате отправления:

Предыдущее
От: Richard Klingler
Дата:
Сообщение: conditional FROM
Следующее
От: David Johnston
Дата:
Сообщение: Re: conditional FROM