Office中国论坛/Access中国论坛

标题: 如何将大量同类型字段的值放到一列中 [打印本页]

作者: zhizhanz    时间: 2009-8-15 03:55
标题: 如何将大量同类型字段的值放到一列中
记录如下:
姓名1         姓名2               姓名3           ……                    姓名30
AAA           BBB               
GGG         
HHH           JJJ                KKK
YYY           III
……

结果希望:
姓名
AAA
BBB
GGG
HHH
……

反正成一列就好
谢谢!
会者不难,请多赐教!
作者: Henry D. Sy    时间: 2009-8-15 10:10
联合查询
作者: zhizhanz    时间: 2009-8-15 15:13
谢谢!
虽然看起来简单又重复。
select [姓名1] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名2] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名3] as [姓名] from [岗位名称对应员工 查询]  UNION select [姓名4] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名5] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名6] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名7] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名8] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名9] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名10] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名11] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名12] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名13] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名14] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名15] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名16] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名17] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名18] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名19] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名20] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名21] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名22] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名23] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名24] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名25] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名26] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名27] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名28] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名29] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名30] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名31] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名32] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名33] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名34] as [姓名] from [岗位名称对应员工 查询] UNION select [姓名35] as [姓名] from [岗位名称对应员工 查询];

谢谢!
作者: Henry D. Sy    时间: 2009-8-15 16:00
用记录集也可以。
作者: ACMAIN_CHM    时间: 2009-8-15 17:37
如下就行了,利用EXCEL的填充功能得到姓名1,姓名2,....姓名n 的序列。
注意代码的风格。

select [姓名1] as [姓名] from [岗位名称对应员工 查询]
UNION ALL
select [姓名2] from [岗位名称对应员工 查询]
UNION ALL
select [姓名3] from [岗位名称对应员工 查询]  
UNION ALL
select [姓名4] from [岗位名称对应员工 查询]
UNION ALL
select [姓名5] from [岗位名称对应员工 查询]
UNION ALL
select [姓名6] from [岗位名称对应员工 查询]
UNION ALL
select [姓名7] from [岗位名称对应员工 查询]
UNION ALL
select [姓名8] from [岗位名称对应员工 查询]
UNION ALL
select [姓名9] from [岗位名称对应员工 查询]
UNION ALL
select [姓名10] from [岗位名称对应员工 查询]
UNION ALL
select [姓名11] from [岗位名称对应员工 查询]
UNION ALL
select [姓名12] from [岗位名称对应员工 查询]
UNION ALL
select [姓名13] from [岗位名称对应员工 查询]
UNION ALL
select [姓名14] from [岗位名称对应员工 查询]
UNION ALL
select [姓名15] from [岗位名称对应员工 查询]
UNION ALL
select [姓名16] from [岗位名称对应员工 查询]
UNION ALL
select [姓名17] from [岗位名称对应员工 查询]
UNION ALL
select [姓名18] from [岗位名称对应员工 查询]
UNION ALL
select [姓名19] from [岗位名称对应员工 查询]
UNION ALL
select [姓名20] from [岗位名称对应员工 查询]
UNION ALL
select [姓名21] from [岗位名称对应员工 查询]
UNION ALL
select [姓名22] from [岗位名称对应员工 查询]
UNION ALL
select [姓名23] from [岗位名称对应员工 查询]
UNION ALL
select [姓名24] from [岗位名称对应员工 查询]
UNION ALL
select [姓名25] from [岗位名称对应员工 查询]
UNION ALL
select [姓名26] from [岗位名称对应员工 查询]
UNION ALL
select [姓名27] from [岗位名称对应员工 查询]
UNION ALL
select [姓名28] from [岗位名称对应员工 查询]
UNION ALL
select [姓名29] from [岗位名称对应员工 查询]
UNION ALL
select [姓名30] from [岗位名称对应员工 查询]
UNION ALL
select [姓名31] from [岗位名称对应员工 查询]
UNION ALL
select [姓名32] from [岗位名称对应员工 查询]
UNION ALL
select [姓名33] from [岗位名称对应员工 查询]
UNION ALL
select [姓名34] from [岗位名称对应员工 查询]
UNION ALL
select [姓名35] from [岗位名称对应员工 查询];





欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3