Skip to Content
0
Former Member
Feb 13, 2006 at 11:30 AM

Formatted search using IF ELSE

141 Views

Hello.

Im trying to do a search with two parameters. If the first one is not empty, do the first search, else do the other search. I get an error. Something about having to select from a table... Anyone?

IF ('[%0]' != '')

BEGIN

SELECT T0.ShortName, T0.Debit, T0.Ref1, T0.Ref2

FROM JDT1 T0

WHERE T0.Debit > '0' AND (T0.Ref1 = '[%0]')

END

ELSE

BEGIN

SELECT T0.ShortName, T0.Debit, T0.Ref1, T0.Ref2

FROM JDT1 T0

WHERE T0.Debit > '0' AND (T0.Ref2 = '[%1]')

END