當(dāng)前位置:首頁(yè) > IT技術(shù) > 數(shù)據(jù)庫(kù) > 正文

mysql中有g(shù)roup_concat()可以合并多行
2021-10-20 10:30:00

select group_concat(CONCAT('if(isnull(',COLUMN_NAME,'),1,0) as ' ,COLUMN_NAME) ) as name ,'aa' as gao from INFORMATION_SCHEMA.COLUMNS
where table_schema='ht_wind' and TABLE_NAME='CBONDBALANCESHEET'?

?

mysql中有g(shù)roup_concat()可以合并多行內(nèi)容,類似于 sqlserver中for xml path

select AID,ANAME,(
select group_concat(VALUE) from B where B.AID=A.AID
) as AVALUE from A;

?

---表名,字段拼接

select TABLE_NAME,group_concat(CONCAT('if(isnull(',COLUMN_NAME,'),1,0) as ' ,COLUMN_NAME) ) as name from INFORMATION_SCHEMA.COLUMNS
where table_schema='ht_wind' group by TABLE_NAME

?

?

本文摘自 :https://www.cnblogs.com/

開通會(huì)員,享受整站包年服務(wù)立即開通 >