SQL 如何在 DB2 中执行 SELECT SUBSTR(COLUMN1, 1, 3), * FROM TABLE1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6534649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to do SELECT SUBSTR(COLUMN1, 1, 3), * FROM TABLE1 in DB2
提问by guanome
In T-SQL you can do following
在 T-SQL 中,您可以执行以下操作
SELECT SUBSTRING(COLUMN1, 1, 3), * FROM TABLE1
SELECT SUBSTRING(COLUMN1, 1, 3), * FROM TABLE1
But in DB2 I get the following error
但是在 DB2 中我收到以下错误
ERROR [42601] [IBM][DB2] SQL0104N An unexpected token "," was found following "". Expected tokens may include: "FROM INTO". SQLSTATE=42601
错误 [42601] [IBM][DB2] SQL0104N 在“”之后发现了意外标记“,”。预期的令牌可能包括:“FROM INTO”。SQLSTATE=42601
Is it possible to do this in DB2?
是否可以在 DB2 中执行此操作?
SELECT SUBSTRING(COLUMN1, 1, 3), * FROM TABLE1
SELECT SUBSTRING(COLUMN1, 1, 3), * FROM TABLE1
NOTE
笔记
I am using asp.net to execute the query above
我正在使用 asp.net 执行上面的查询
EDIT
编辑
I want to be able to grab everything but do a substring or a small calculation on one of the columns. I want to do a substring on one of the columns but I don't want to list out every column.
我希望能够抓取所有内容,但对其中一列进行子字符串或小计算。我想在其中一列上做一个子字符串,但我不想列出每一列。
采纳答案by a_horse_with_no_name
As already stated by maple_shaft your question doesn't really make sense, but the following should work (cannot try it right now though)
正如 maple_shaft 已经指出的那样,您的问题实际上没有意义,但以下应该有效(尽管现在无法尝试)
SELECT Column1, table1.*
FROM TABLE1
回答by niktrs
Without the ing
没有ing
SELECT SUBSTR(COLUMN1, 1, 3), * FROM TABLE1
回答by thevan
To select all the columns:
要选择所有列:
SELECT Table1.* FROM Table1