Forum > Databases

Best way to update data from linked tables using navigator and DBGrid?


Lazikas o Pontios:
HI to all!

I use the following sql query in order to show some data from main table (agros), that is linked with 3 more tables (but for the moment i pull data from 2 of them), into a DBGrid:

agros_sql_Query = 'Select owners.Name, koino.Name as Koinotita , agros.* from agros, owners, koino where = agros.owner_id and = agros.koino_id';

The connections are :
Query1.SQL.Text:=   agros_sql_Query ; //the query is define above

The result is as expected, as you can see from the attached photo(first two fields are pulled from other tables). But the navigator is now almost disabled ( i guess it is normal behavior) since the dbgrid is not connected to a single table but into a 'virtual' one. So far, so good.
Now i want to be able to update/correct  the data from the main table (agros). Hense, the fields from Code up to Year. But since the navigator is almost disabled, i cannot.

And the main question is : Is there a workaround to update records (using or not the dbgrid)?  I want to avoid creating forms for each table because the table agros is a middle table that will be linked to other tables in one to many relation and the other tables have dozens of fields.

If it's TLTR, the question can be summurised to : Can i update a row of one table while i MUST see data from other tables that are related to that row (preferably in a DBGrid)  ?

in the UpdateSQL property, you can set an individual query that updates the data - sample in attachment

Lazikas o Pontios:
TYVM, you are a life saver !!! It worked like charm, even with MYSQL database  :D :D :D O:-).


[0] Message Index

Go to full version