Derived Master - Detail Field

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

Derived Master - Detail Field

Post by waheed » Tue 10 Nov 2009 21:04

Problem Description:
I have Master Detail connection problem:

Master key values are
0, 100, 200, 300, 400, 500, 600, ..., 900

Detail key values are
10, 20, 110, 120, 130, 410, 420, ... 990

If I don't want to change the structure of the table, how can I create a master/detail relationship between them.

Here is my trial solution which I didn't know how to finish:

Master Query:
Select mkey, mname
from Mast

Detail Query:
SELECT dkey, dname,
(codeid DIV 100 * 100) AS CalKey
FROM Det
where CalKey=:mkey

then in the detail MyQuery component I set the MasterSource Prop to the master MyQuery component . And the MasterField to the master mkey. And the DetailFields to CalKey

This didn't work (the error was "#42S22Unknown column 'CalKey' in 'where clause'.", what is the proper way to do this?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 12 Nov 2009 14:30

Try to use the following detail query:

Code: Select all

SELECT dkey, dname
FROM Det 
where (codeid DIV 100 * 100)=:mkey 

waheed
Posts: 20
Joined: Mon 02 Nov 2009 19:47
Location: Kuwait

Post by waheed » Thu 12 Nov 2009 15:32

Thaaaaanks, this did it.

Post Reply