MySQL 如何创建制表符分隔的选择语句?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8046832/
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 create Tab Delimited Select statement?
提问by meetpd
I need to combine columns with select statment such that it create a tab delimited file.
我需要将列与 select 语句结合起来,以便创建一个制表符分隔的文件。
For. e.g
为了。例如
Select ColumnA || "," || ColumnB
Above statement will create Comma Seperate File. What should I write to create Tab delimited file?
以上语句将创建逗号分隔文件。我应该写什么来创建制表符分隔的文件?
Please let me know.
请告诉我。
回答by Micha? Powaga
MySQL:
MySQL:
select concat(ColumnA, "\t" ,ColumnB)
SQL Server:
SQL 服务器:
select ColumnA + char(9) + ColumnB
Oracle:
甲骨文:
select ColumnA || chr(9) || ColumnB
回答by Osmin
If I understand your question, you should try this:
如果我理解你的问题,你应该试试这个:
SELECT CONCAT(ColumnA, '\t', ColumnB)
回答by Piotr Auguscik
Tab is char(9)
in Microsoft SQL Server.
选项卡char(9)
位于 Microsoft SQL Server 中。
source: http://msdn.microsoft.com/en-us/library/ms187323.aspx
回答by Ponytech
Postgresql:
PostgreSQL:
select concat(ColumnA, chr(9), ColumnB)