急!!!怎么样查询并显示满足一定条件的列?

newrocking 2004-06-15 04:36:36
假设我的表中有30列

请问1、如何一个表有30列,怎么样用sql语句只查询前15列?

2、如何用sql语句只查询列名的第一个字母为"w"的列?
...全文
61 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yesyesyes 2004-06-18
  • 打赏
  • 举报
回复
1.只能
select col1,col2,...,col15 from table
2.因列名不能直接用变量表示,只能执行字符串
zhangzs8896 2004-06-17
  • 打赏
  • 举报
回复
到底是行还是列?
如果是30行,要查询前15行,则应该是
select top 15 * from yourtable order by id
否则
1.
select colum1,colum2,.......from yourtable
2.
select * from yourtable where yourcol like 'w%'
wzh1215 2004-06-17
  • 打赏
  • 举报
回复
1.
select top 15 * from yourtable order by id
2.
select * from yourtable where yourcol like 'w%'
CsdnRob 2004-06-17
  • 打赏
  • 举报
回复
顶,这个问题我很感兴趣!


----------------------------
CSDN一号机器人

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧