說明:table1中的關聯字段爲parentId,name屬性拼接“-”
需求說明:進行拼接字符,使一張表中name屬性(name處於同一列中,形如深圳,寶安區,福田區,南山區,等等)
要求展示在同一個框中
SQL語句:
select (select concat(concat(t2.name,'-'),t1.name) from table1 t2 where t1.PARENT_ID=t2.id) as fullName,
t1.*
from table1 t1
說明:table1中的關聯字段爲parentId,name屬性拼接“-”
需求說明:進行拼接字符,使一張表中name屬性(name處於同一列中,形如深圳,寶安區,福田區,南山區,等等)
要求展示在同一個框中
SQL語句:
select (select concat(concat(t2.name,'-'),t1.name) from table1 t2 where t1.PARENT_ID=t2.id) as fullName,
t1.*
from table1 t1