Edit and update a joined queries

﹥>﹥吖頭↗ 提交于 2019-12-13 23:03:50

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!