Getting information out of MYSQL

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Getting information out of MYSQL

Post by kaffeburk » Sat 07 Apr 2007 01:34

Is there any simple way to get for example the mid value for a selcted column?

I guess i could create SQL code to transfer that value to a specific cell, and then read it...

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 10 Apr 2007 08:16

You can do this using code like this:

Code: Select all

  MyQuery.SQL.Text := 'SELECT AVG(field_name) FROM table_name';
  MyQuery.Open;
  ShowMessage('Average value: ' + MyQuery.Fields[0].AsString);
For more information on functions like AVG read the MySQL Reference Manual.

Post Reply