Subject | Re: [firebird-support] One query either of the two WHERE clause |
---|---|
Author | Venus Software Operations |
Post date | 2013-11-26T11:57:47Z |
On 24 Nov 2013 23:46:29 -0800, <venussoftop@...> wrote:
> Hi all
>
> I have a query in which I need to use either of two WHERE clauses
> depending on the parameters passed or no parameter passed to the query
(via
> Remote View in VFP)
...
>
> Please advise on if and how I can have two different WHERE clause
> depending on external parameters having values. Till now I have passed
> parameters but the WHERE has always been one that adapted to the values
> passed as parameters.
I found your where clauses not very readable, so I'll give a general
recipe:
SELECT
...
FROM ....
WHERE <condition for first-set-of-conditions> AND
(<first-set-of-conditions>)
OR <condition for second-set-of-conditions> AND
(<second-set-of-conditions>)
EG
SELECT
*
FROM mytable
WHERE ? IS NULL AND (x=y)
OR ? IS NOT NULL AND (x=? OR y=?)
Mark
Thanks a lot Matt that was helpful I was able to alternate between use of parameters and no parameters. As a bonus I created SP for the complex sub queries in the original WHERE clause
Kind regards
Bhavbhuti