TmyQuery Update

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
khh
Posts: 37
Joined: Wed 17 Nov 2004 17:10

TmyQuery Update

Post by khh » Wed 04 Oct 2006 10:35

I have this query attached to DBGrid

Code: Select all

SELECT
  tbl_pupils.ID,
  CONCAT(tbl_pupils.FirstName, " ", tbl_pupils.LastName) AS FullName,
  tbl_subjects.title,
  tbl_grades.ft,
  tbl_grades.fp,
  tbl_grades.ft + tbl_grades.fp AS total
FROM
  tbl_grades,
  tbl_pupils,
  tbl_subjects
WHERE
  tbl_grades.PID = tbl_pupils.ID AND
  tbl_grades.BID = tbl_subjects.ID

How to update (ft & fp) in (Grades) table using this SQL with DBGrid.

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

Post by Antaeus » Thu 05 Oct 2006 10:06

We can suggest two ways to solve this problem. The first one is to set name of the table you want to edit to UpdatingTable property of TMyQuery component. The second way is to assign corresponding SQL statement to SQLUpdate property. It will be executed on each post of edited record.

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

Post by Antaeus » Thu 05 Oct 2006 10:27

Note that you should include primary key of the table you want to edit into your SELECT statement.

Post Reply