What does SQL Select symbol || mean?

那年仲夏 提交于 2019-11-27 14:37:18
collapsar

|| represents string concatenation. Unfortunately, string concatenation is not completely portable across all sql dialects:

  • ansi sql: || (infix operator)
  • mysql: concat ( vararg function ). caution: || means 'logical or' (It's configurable, however; thanks to @hvd for pointing that out)
  • oracle: || (infix operator), concat ( caution: function of arity 2 only ! )
  • postgres: || (infix operator)
  • sql server: + (infix operator), concat ( vararg function )
  • sqlite: || (infix operator)

hopefully the confusion is complete ...

John Hartsock

It is a concat statement. It will concatenate the two strings.

Here is a helpful post!

What is the difference between "||" operator and concat function in Oracle?

SELECT 'a' || ',' || 'b' AS letter will combine a letter. The result become 'a,b'

In Oracle, SQLite3, and MySQL, it concatenates strings. Please see the Oracle documentation. The MySQL documentation.

Also, it's part of ANSI SQL, but read this for more information.

It's a concatenation operator. So you would get 'a,b' from that. I think || will work on most RDBMS's. SQL Server requires the + operator (thanks to HVD for setting me straight!).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!