如何编写除一列以外的选择查询

编程入门 行业动态 更新时间:2024-10-27 08:33:56
本文介绍了如何编写除一列以外的选择查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有20列作为日期,col1,col2 .... col19。 i想要显示除日期列之外的所有列。 如何写查询。

i have 20 columns as date,col1,col2....col19. i want to display all columns except date column. how to write query for that.

推荐答案

从select语句中删除该列并放入所有其他列名。 或者您可以绑定所有列并隐藏特定的代码中的列。例如,如果将数据绑定到GridView,则添加RowDataBound事件并将第一列隐藏为; remove that column from your select statement and put all other column names. Or you can bind all the columns and hide specific column from code. for example if you bind data to GridView then add RowDataBound event and hide the first column as; protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Cells[0].Visible = false; }

参考:是否可以编写选择*除了表中的(column1,column2,..)

如果您要经常使用此查询,则以前解决方案的另一种替代方法是创建查看 [ ^ ]数据。 同样的限制适用(即你可以不要说除了这些列,但查询只会在SSMS中编写或构建一次。在更高版本的sql中,您可以为视图索引性能。 如果表中有60列,那么您可能想重新考虑表模式并使用一些规范化技术 [ ^ ] Another alternative to the previous solutions, if you are going to use this query frequently, is to create a View[^] of the data. The same restrictions apply (i.e. you can't say "except these columns") but the query will only be written, or built in SSMS, once. In later versions of sql you can index views for performance. If you have 60 columns in your table then you might like to re-consider your table schema and employ some normalization techniques[^]

更多推荐

如何编写除一列以外的选择查询

本文发布于:2023-10-28 13:51:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536808.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!