Relational / Hierarchical Select

Relational / Hierarchical Select

Postby KW » Thu 28 Feb 2008 02:57

Is there an elegant way to do a select on a parent table which then only retrieves its child rows based on what was selected in the parent table?

Basically, I'd like to use the built in feature of startrecord and maxRecords. I'd like to say, give me the first 4k records of this parent table and also retrieve all child tables that belong to the selected 4k records. In this way, you won't fail a contraint check, where as you would possibly if you said just give me the first 4k records in both parent and child tables. Obviously, in a larege database you can't simply say Select all.

Is there a built in way to do this?
Posts: 123
Joined: Tue 19 Feb 2008 19:12

Postby Alexey.mdr » Thu 28 Feb 2008 12:41

Unfortunately, we do not provide such built-in functionality.

Probably, if the selecting criteria for the parent table is known beforehand you might use this code:
Code: Select all
SELECT * FROM childTable WHERE (FK_id_PT = SELECT id_PT FROM parantTable WHERE (columnName=:paramName));

Additionally, if you are making a master-detail datagrids you might be interested in the following sample:
%Program Files%CoreLab\MyDirect.NET2\Samples\WinForms\
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Return to dotConnect for MySQL