Difference between revisions of "LEFT"

From SQLZOO
Jump to: navigation, search
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>LEFT(s,i)</th></tr> <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</...")
 
Line 5: Line 5:
 
<tr><td align='left'>ingres</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>ingres</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>mysql</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>mysql</td><td>Yes</td><td></td></tr>
<tr><td align='left'>oracle</td><td>No</td><td>[[SUBSTR(s, 1, i)]]</td></tr>
+
<tr><td align='left'>oracle</td><td>No</td><td>[[SUBSTR |SUBSTR(s, 1, i)]]</td></tr>
<tr><td align='left'>postgres</td><td>No</td><td>[[SUBSTRING(s, 1, i)]]</td></tr>
+
<tr><td align='left'>postgres</td><td>No</td><td>[[SUBSTRING |SUBSTRING(s, 1, i)]]</td></tr>
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td></td></tr>
 
</table>
 
</table>
Line 36: Line 36:
 
<p>See also</p>
 
<p>See also</p>
 
<ul>
 
<ul>
   <li>[[SUBSTRING function]]</li>
+
   <li>[[SUBSTRING |SUBSTRING function]]</li>
   <li>[[RIGHT function]]</li>
+
   <li>[[RIGHT |RIGHT function]]</li>
   <li>[[POSITION function]]</li>
+
   <li>[[POSITION |POSITION function]]</li>
 
</ul>
 
</ul>

Revision as of 15:04, 16 July 2012

Compatibility
LEFT(s,i)
EngineOKAlternative
ingresYes
mysqlYes
oracleNoSUBSTR(s, 1, i)
postgresNoSUBSTRING(s, 1, i)
sqlserverYes

LEFT

LEFT(s,n) allows you to extract n characters from the start of the string s.

   LEFT('Hello world', 4) -> 'Hell'     
SELECT name,
       SUBSTRING(name, 1, 3)
  FROM bbc
SELECT name,
       SUBSTR(name, 1, 3)
  FROM bbc
SELECT name,
       LEFT(name, 3)
  FROM bbc

See also

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense