日期:2014-05-17  浏览次数:20513 次

多个表,多个列转换为1列,并消除空白
表T1、T2、T3、T4、T5,结构(只列出通用的部分),UserId Title Content Pic1 Pic2 Pic3 ...

目的,统计一个用户上传的图片。列出多个表里UserId=5的会员上传的图片的列表(其中Pic1 Pic2 Pic3)可能有''空字符

------解决方案--------------------
用union all合并再选择
------解决方案--------------------
试试
select
  *
from
  (
   select pic1 from t1
   union all
   select pic2 from t1
....
  )t
where
  useid=5