编辑和更新联接的查询

时间:2019-08-20 03:06:49

标签: sql delphi join edit

我有四个表FDQueries(Firebird 3.0)国家,地区,部门和城市,还有第五个temporay FDQuery,在其中显示CITIES表以及来自其他表的相关数据,如下所示:

import random

def topic_ch():
    print ("hello you have 3 topics chose your topic by preesing the topic number \n 1-random asking \n 2- quizz")
    topc = input()
    if topc == "1":
        topic_1()


def topic_1():
    set1 = {1: "who is the presedint of USA ? :\n -1 D.Trump         2-Emmanuel Macron\n -3 George W. Bush       4-Bill Clinton:",
       2:"who is the presedint of France ? :\n -1 D.Trump           2-Emmanuel Macron\n -3  George W. Bush       4-Bill Clinton:"}
    print (random.choice(set1))
    ans = input()
    for set1[1] in set1:
        if ans == "1":
            print ("correct")
            break
        else:
            print ("opss")
            break
        for set1[2] in set1:
            if ans == "3":
                print ("correct")
                break


topic_ch()

该连接工作正常,并显示了我想要的内容:

现在完成了,我希望用户直接从显示联接表的网格中编辑CITIES表(临时的)。我的问题是如何使用仅发布原始CITIES表的简单方式进行正确的更新

非常抱歉,我第一个提出问题

1 个答案:

答案 0 :(得分:0)

您可以使用以下查询通过联接更新表-

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;

您可以阅读this文章以进行进一步更新。