This commit is contained in:
vipg
2025-11-19 16:33:48 +08:00
parent edfc11d198
commit c661084bb8
2 changed files with 145 additions and 8 deletions

View File

@@ -98,17 +98,19 @@ BEGIN
CREATE OR REPLACE VIEW country_info_view AS
SELECT
u.id AS country_id,
n.name AS name,
c.code AS code,
u.deleted AS deleted
n.name AS country_name, -- 国家名称
c.code AS country_code, -- 国家代码
f.flag AS country_flag, -- 国旗信息
FROM
country u
JOIN
country_name n ON u.id = n.country_id
JOIN
country_code c ON u.id = c.country_id
LEFT JOIN
country_name n ON u.id = n.country_id AND n.deleted = FALSE -- 过滤已删除名称
LEFT JOIN
country_code c ON u.id = c.country_id AND c.deleted = FALSE -- 过滤已删除代码
LEFT JOIN
country_flag f ON u.id = f.country_id AND f.deleted = FALSE -- 左连接:允许无国旗数据
WHERE
u.deleted = FALSE;
u.deleted = FALSE; -- 只查询未删除的国家
-- 根据视图是否已存在输出不同提示
IF view_exists THEN