yanttong
2024-12-23 17:36:04
最佳回答
1数据库中業種的存储如下图:select * from m_torihik**aki_gyosyu1本页面非法爬取自百度经验2其中gyiusyu_cd字段代表不同的業種而画面需要实现下图所示样式:(将每条数据的業種横向展开显示)3这种情况下便可以使用pivot方法,代码如下:select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12from m_torihik**aki_gyosyupivot(max(gyiusyu_cd)for gyiusyu_cd in(1 as c1,2 as c2,3 as c3,4 as c4,5 as c5,6 as c6,7 as c7,8 as c8,9 as c9,10 as c10,11 as c11,12 as c12))其执行结果为:4为实现页面效果,可使用decode方法,sql片段如下 decode(c1,1 ,'true','false') as c1 ,decode(c2,2 ,'true','false') as c2 ,decode(c3,3 ,'true','false') as c3 ,decode(c4,4 ,'true','false') as c4 ,decode(c6,6 ,'true','false') as c6 ,decode(c7,7 ,'true','false') as c7 ,decode(c8,8 ,'true','false') as c8 ,decode(c9,9 ,'true','false') as c9 ,decode(c10,10 ,'true','false') as c10,decode(c11,11 ,'true','false') as c11 ,decode(c12,12 ,'true','false') as c12 这样,检索后的结果就是true 或 false ,然后将检索结果赋给checkbox,就能按要求显示了。end 20210311