我希望 parent 在此查询中是唯一的:
select
*,
(select state_name
from tbl_states
where state_id = tbl_cities.parent_id) as parent
from
tbl_cities
ORDER BY
parent
我试过使用:
select
*,
DISTINCT (select state_name
from tbl_states
where state_id = tbl_cities.parent_id) as parent
from
tbl_cities
ORDER BY
parent
但它给出了一个错误。