consolidate query with template %ifvar% in database webserv

Hello,
I try to put the underneath 2 queries in one ‘database web service’. The query has to search data on myTable1.col1=? or myTable2.col2 =?

query 1:
select myTable1.col1,myTable2.col2
from myTable1,myTable2
where myTable1.col1=?
and myTable1.ID=myTable2.ID

query2:
select myTable1.col1,myTable2.col2
from myTable1,myTable2
where myTable2.col2 =?
and myTable1.ID=myTable2.ID

I have tried to make something as

select myTable1.col1,myTable2.col2
from myTable1,myTable2
where (myTable1.col1=? or myTable2.col2 =? )
and myTable1.ID=myTable2.ID

But this is very slow and not working well.

Could you please advice if I can use template tag
%ifvar% or something to resolve the problem.

Or may be there is otherway ?

Thanks very much for the help,
Quoi

Since the data may not be in both tables and full join won’t work for you. Maybe try an outer join.

Here is some info on Oracle:
http://www.oreillynet.com/pub/a/network/2002/04/23/fulljoin.html
Here is some info on SQL Server:
http://www.microsoft.com/sql/techinfo/tips/development/July23.asp

HTH,
Fred