在SQL中获取递归父项

时间:2017-08-02 11:41:54

标签: mysql sql

我使用此查询来获取客户的父母但却没有返回结果:

select KONTO, CUSTOMER_NUMBER, COLLATERAL_TYPE, 1 as MATURITY
from t
where MATURITY >= 1
union all
select KONTO, CUSTOMER_NUMBER, COLLATERAL_TYPE, 2 as MATURITY
from t
where MATURITY >= 2
union all
select KONTO, CUSTOMER_NUMBER, COLLATERAL_TYPE, 3 as MATURITY
from t
where MATURITY >= 3
union all
select KONTO, CUSTOMER_NUMBER, COLLATERAL_TYPE, 4 as MATURITY
from t
where MATURITY >= 4
union all
select KONTO, CUSTOMER_NUMBER, COLLATERAL_TYPE, 5 as MATURITY
from t
where MATURITY >= 5;

此查询有什么问题?

0 个答案:

没有答案