设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1039|回复: 4
打印 上一主题 下一主题

[查询] 如何将大量同类型字段的值放到一列中

[复制链接]
跳转到指定楼层
1#
发表于 2009-8-15 03:55:40 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
记录如下:
姓名1         姓名2               姓名3           ……                    姓名30
AAA           BBB               
GGG         
HHH           JJJ                KKK
YYY           III
……

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

反正成一列就好
谢谢!
会者不难,请多赐教!
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
5#
发表于 2009-8-15 17:37:39 | 只看该作者
如下就行了,利用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 [岗位名称对应员工 查询];
4#
发表于 2009-8-15 16:00:53 | 只看该作者
用记录集也可以。
3#
 楼主| 发表于 2009-8-15 15:13:35 | 只看该作者
谢谢!
虽然看起来简单又重复。
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 [岗位名称对应员工 查询];

谢谢!
2#
发表于 2009-8-15 10:10:16 | 只看该作者
联合查询
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-11-19 20:44 , Processed in 0.090020 second(s), 29 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表