Page 1 of 1

Solved: UNION and FilterSQL

Posted: Tue 16 Jun 2015 11:04
by waheed
I have an sql statement with a union. But when I added a FilterSQL to the TMyQuery the result was not filtered, only the last select was filtered the first was not.
Any thoughts?

I have found a solution: Put the whole union in a select like this:

Code: Select all

Select * from 
( select * from table1
union 
select * from table2) as resulttable
Now when I do a filter it is applied to the result as a whole.

Thanks

Re: Solved: UNION and FilterSQL

Posted: Tue 16 Jun 2015 13:46
by ViktorV
You have found a correct solution for the problem, since the value of the TMyQuery.FilterSQL property is added to the last WHERE clause of your SQL query.