【问题标题】:SQL query for specific columns returns all of the columns特定列的 SQL 查询返回所有列
【发布时间】:2022-11-17 04:50:42
【问题描述】:

我正在发送一个特定的查询

select top 10 IsPassed, Line, *
from dw.table1 f
join dw.table2 d on f.StationID = d.StationID
where StationType like '%BAM%'

我希望它只返回 2 列IsPassed。和Line,但是,这将返回 2 个表中的每一列,并且只是将 2 列附加到前面。

我怎样才能将其更改为仅返回那两列?

【问题讨论】:

  • 删除*

标签: sql sql-server odbc


【解决方案1】:

从选择列表中删除“*”。查询看起来像这样:

select top 10 IsPassed, Line
from dw.table1 f
join dw.table2 d on f.StationID = d.StationID
where StationType like '%BAM%'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-08
    • 1970-01-01
    • 2013-08-29
    相关资源
    最近更新 更多