我在表id_org
中有3列(code_org
,id_root_org
,org
)。 id_root_org
指定表中某个组织的最高组织。
org 1 (id_org=1, id_root_org = 1 since it is its own root)
--org 2 (id_org=2, id_root_org = 1)
--org 3 (id_org=3, id_root_org = 1)
--org 3.1 (id_org=3.1, id_root_org = 1)
如何检索所有根组织的代码?
答案 0 :(得分:1)
看来,根是id_root_org = id_org
所在的记录。要获得该行的code_org
,您可以使用简单的SELECT
。
SELECT code_org
FROM elbat
WHERE id_root_org = id_org;
答案 1 :(得分:0)
您只想要ID_ROOT_ORG的列表?
SELECT DISTINCT ID_ROOT_ORG
FROM [TABLE_NAME]