What does SQL Select symbol || mean?

user3586553 picture user3586553 · Apr 29, 2014 · Viewed 87.5k times · Source

What does || do in SQL?

SELECT 'a' || ',' || 'b' AS letter

Answer

collapsar picture collapsar · Apr 29, 2014

|| 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 ...