| |
| |
| LOOKUP COLUMN TUTORIAL |
| Home |
 |
Articles |
 |
DBGridView |
|
 |
With using Lookup Column we can combine Fields of 2 Tables or Queries
to get result similiar when using SQL Join commands. Sometime we need
to display some Field from first table with using Field from second Table.
In next example we have 2 tables: Articles
and Article_types
| Articles |
| id |
name |
article_type_id |
| 1 |
Keyboard |
1 |
| 2 |
Mouse |
1 |
| 3 |
WindowsXP |
2 |
| 4 |
Delphi |
2 |
and second one:
| Article_types |
| id |
name |
| 1 |
Hardware |
| 2 |
Software |
to get next result:
| id |
name |
article_type_id |
| 1 |
Keyboard |
Hardware |
| 2 |
Mouse |
Hardware |
| 3 |
WindowsXP |
Software |
| 4 |
Delphi |
Software |
To made this, we need to have 2 TTable (TADOTable,
TIBTable, TZTable...)
and 2 TDataSource components on placed form.
KeyFieldName - Field from second Table
ListDataSource - Set to second DataSource
ListFieldName - Set to displaying Field from
second Table. In our case is name. |
|