Re: Query Formulation Question

Поиск
Список
Период
Сортировка
От Sean Davis
Тема Re: Query Formulation Question
Дата
Msg-id 446534D9.3010509@mail.nih.gov
обсуждение исходный текст
Ответ на Re: Query Formulation Question  (<operationsengineer1@yahoo.com>)
Список pgsql-novice
operationsengineer1@yahoo.com wrote:
>>operationsengineer1@yahoo.com wrote:
>>
>>>consider the following simplified queries (php
>>
>>using
>>
>>>heredoc):
>>>
>>>$sql_1 = <<<_EOSQL
>>>
>>>select count(inspect)
>>>from t_inspect, t_product, t_test_area
>>>where t_product.product_num = 1
>>>and t_test_area.id = 5
>>>
>>>_EOSQL
>>>
>>>$sql_2 = <<<_EOSQL
>>>
>>>select count(inspect)
>>>from t_inspect, t_product, t_test_area
>>>where t_product.product_num = 1
>>>
>>>_EOSQL
>>>
>>>what is the best way to handle both of these cases
>>
>>in
>>
>>>one statement?
>>
>>You are using a programming language--why not
>>construct the query on the
>>fly?
>
>
> the simple answer is i don't know how.  btw, that's
> the complex answer, too.  ;-)  can you share a quick
> example?
>
>
>>Why the requirement to use the heredoc for the
>>entire query string?
>
>
> that's not a requirement.  i like the heredoc format
> for readability and ease of c&p to pgadmin3's query
> executer.  however, i'm not married to it and will use
> another option when i have a good reason.
>
> based on your comments, i could use a heredoc for the
> base query and then check to see if i need to
> concatenate the where statement to it.  i think that
> will work.

That sounds reasonable.  You might look at a database abstraction layer.
  I'm not sure what is available for php, though.

Sean

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

Предыдущее
От:
Дата:
Сообщение: Re: Query Formulation Question
Следующее
От:
Дата:
Сообщение: Q on requirement to connect to a specific DB