`
ranyut
  • 浏览: 255511 次
  • 性别: Icon_minigender_1
  • 来自: 重庆
社区版块
存档分类
最新评论

用一句SQL实现给查询数据结果添加虚拟数据并排在最前面

阅读更多
由于项目的特殊要求,需要给查询出来的数据中添加一列特殊虚拟数据,如名为“查询所有单位”的一列数据,并要求排在所有结果的最前面;
可由一句SQL来实现:
select -1 cid,'asy' ccode ,'在所有单位中查询' cfullname from dual 
union 
select t.cid,t.ccode,t.cfullname from GS_UNITINFO t

( 心得积累)
分享到:
评论
1 楼 lelinghong 2010-01-27  
hao !我也填一条

select '通讯工具' as tbName,code,called from P_SJ_ZL,dual
union
select '家电电器',code,called from P_JD_ZL,dual
union
select '运输工具',code,called from P_CL_ZL,dual
union
select '金银首饰',code,called from P_JY_ZL,dual
union
select '其他类别',code,called from P_QT_ZL,dual

相关推荐

Global site tag (gtag.js) - Google Analytics