问题
I have four tables FDQueries (Firebird 3.0) COUNTRIES, REGIONS, DEPARTMENTS, AND CITIES and a fifth temporay FDQuery where to display CITIES table with related data from others tables as following :
SELECT C.NAMEXXX AS NAMEXXX, D.NAMEXXX as NAMEXXX, R.NAMEXXX AS NAMEXXX, T.NAMEXXX AS NAMEXXX
FROM GEOCITI C
LEFT JOIN GEODEPT D ON D.PKINDEX = C.FKDEPAR
LEFT JOIN GEOREGI R ON R.PKINDEX=D.FKREGIO
LEFT JOIN GEOCOUN T ON T.PKINDEX=R.FKCOUNT
The join is working perfectly and showing what i want :
Now this done, i want the user to edit the CITIES table directly from the Grid showing the joined table (Temporary) My question is how to do this the right way to update with a simple post only original CITIES Table
Thanks and sorry for my first question formulation
回答1:
You can use following query to update table using join -
UPDATE CITIES
SET CITYPOPULATION = YOUR_UPDATED_VALUE
FROM CITIES C
JOIN DEPARTMENTS D ON C.departmentname = D.NAME
JOIN COUNTRIES CT ON D.countryname = CT.name;
You can read this article for further update.
来源:https://stackoverflow.com/questions/57566203/edit-and-update-a-joined-queries