Solved: UNION and FilterSQL

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
waheed
Posts: 20
Joined: Mon 02 Nov 2009 19:47
Location: Kuwait

Solved: UNION and FilterSQL

Post by waheed » Tue 16 Jun 2015 11:04

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

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Solved: UNION and FilterSQL

Post by ViktorV » Tue 16 Jun 2015 13:46

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.

Post Reply