Is is possible to get the field expression from TMyQuery?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Justmade
Posts: 108
Joined: Sat 16 Aug 2008 03:51

Is is possible to get the field expression from TMyQuery?

Post by Justmade » Wed 10 Aug 2011 16:01

SQL :
SELECT Table1.FieldA, CONCAT(Table1.FieldB,TABLE2.FieldC) AS FieldD
FROM Table1 LEFT JOIN Table2.....

Is it possible to get back CONCAT(Table1.FieldB,TABLE2.FieldC) from TMyQuery or TField of FieldD?

In TField, FieldD FieldName is of cause FieldD but the origin is also FieldD.

I would like the original expression (base on user choice of filters etc) to create another SQL with Where or so.

Thanks you!

AndreyZ

Post by AndreyZ » Thu 11 Aug 2011 10:12

Hello,

The point is that when you use alias, MySQL returns alias for both field name and field original name. You can change your SQL code basing on your users' choice. Here is an example:

Code: Select all

SELECT Table1.FieldA, CONCAT(Table1.FieldB,TABLE2.FieldC) AS FieldD 
FROM Table1 LEFT JOIN Table2.....

SELECT Table1.FieldA, CONCAT(Table1.FieldB,TABLE2.FieldC)
FROM Table1 LEFT JOIN Table2.....
or
SELECT Table1.FieldA, CONCAT(Table1.FieldB,TABLE2.FieldC) AS 'CONCAT(Table1.FieldB,TABLE2.FieldC)'
FROM Table1 LEFT JOIN Table2.....

Post Reply