Difference between revisions of "Concatenate strings"

From SQLZOO
Jump to: navigation, search
(Created page with "Concatenate strings. <div class='ht'> <div class=params>schema:gisq</div> <div> Concatenation means "stick strings together". In this example we concatenate three strings, '''...")
 
 
Line 10: Line 10:
 
<source lang=sql class='setup'></source>
 
<source lang=sql class='setup'></source>
 
<source lang='sql' class='def e-access'>SELECT name & ' is in ' & region
 
<source lang='sql' class='def e-access'>SELECT name & ' is in ' & region
   FROM cia
+
   FROM bbc
 
   WHERE name LIKE 'D%'</source>
 
   WHERE name LIKE 'D%'</source>
 
<source lang='sql' class='def e-sqlserver'>SELECT name + ' is in ' + region
 
<source lang='sql' class='def e-sqlserver'>SELECT name + ' is in ' + region
  FROM cia
+
  FROM bbc
 
  WHERE name LIKE 'D%'</source>
 
  WHERE name LIKE 'D%'</source>
 
<source lang='sql' class='def e-mysql'>SELECT CONCAT(name, ' is in ', region)
 
<source lang='sql' class='def e-mysql'>SELECT CONCAT(name, ' is in ', region)
   FROM cia
+
   FROM bbc
 
   WHERE name LIKE 'D%'</source>
 
   WHERE name LIKE 'D%'</source>
 
<source lang='sql' class='def'>SELECT name || ' is in ' || region
 
<source lang='sql' class='def'>SELECT name || ' is in ' || region

Latest revision as of 14:16, 17 July 2012

Concatenate strings.

schema:gisq

Concatenation means "stick strings together". In this example we concatenate three strings, name and region are string attributes of the table, ' is in ' is a string literal.

 
 
SELECT name & ' is in ' & region
  FROM bbc
  WHERE name LIKE 'D%'
SELECT name + ' is in ' + region
 FROM bbc
 WHERE name LIKE 'D%'
SELECT CONCAT(name, ' is in ', region)
  FROM bbc
  WHERE name LIKE 'D%'
SELECT name || ' is in ' || region
 FROM bbc
 WHERE name LIKE 'D%'


Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense