SQL语句:
-- sql写法
-- 准入到省
select * from
t_city where id in
(
select t.id
from t_city t
LEFT JOIN t_city_product tcp on tcp.city_id = t.id
where t.is_delete = 0 and tcp.product_id = 2
) or parent_id in (
select t.id
from t_city t
LEFT JOIN t_city_product tcp on tcp.city_id = t.id
where t.is_delete = 0 and tcp.product_id = 2
)
-- 接口写法
-- 接口1
select t.*
from t_city t
LEFT JOIN t_city_product tcp on tcp.city_id = t.id
where t.is_delete = 0 and tcp.product_id = 2
-- 接口2 把接口1查询回来的id放入
select * from
t_city where id in (2,20) or parent_id in (2,20)
-- sql写法
-- 准入到市
select * from
t_city where id in
(
select t.id
from t_city t
LEFT JOIN t_city_product tcp on tcp.city_id = t.id
where t.is_delete = 0 and tcp.product_id = 1
) or id in (
select t.parent_id
from t_city t
LEFT JOIN t_city_product tcp on tcp.city_id = t.id
where t.is_delete = 0 and tcp.product_id = 1
)