SQL handleiding

SQL TUIS SQL Inleiding SQL-sintaksis SQL Kies SQL Kies Distinct SQL Waar SQL En, of, nie SQL Bestel deur SQL Voeg in SQL nulwaardes SQL-opdatering SQL verwyder SQL Kies Top SQL Min en Max SQL-telling, gemiddeld, som SQL Soos SQL Wildcards SQL in SQL Tussen SQL aliasse SQL sluit aan SQL Inner Sluit aan SQL Links Sluit aan SQL Reg Sluit aan SQL Volledige Aansluiting SQL Self Sluit aan SQL Unie SQL Groep deur SQL het SQL bestaan SQL Enige, Almal SQL Kies In SQL Voeg in Kies SQL-geval SQL nul-funksies SQL gestoorde prosedures SQL opmerkings SQL-operateurs

SQL- databasis

SQL Skep DB SQL Drop DB SQL Backup DB SQL Skep tabel SQL Drop Tabel SQL Verander Tabel SQL-beperkings SQL nie nul nie SQL Uniek SQL Primêre Sleutel SQL buitelandse sleutel SQL Check SQL verstek SQL-indeks SQL Outo-verhoging SQL datums SQL-aansigte SQL-inspuiting SQL Hosting SQL-datatipes

SQL- verwysings

SQL sleutelwoorde MySQL-funksies SQL Server funksies MS Access-funksies SQL Vinnige Verw

SQL voorbeelde

SQL voorbeelde SQL vasvra SQL-oefeninge SQL-sertifikaat

MySQL SUBSTR() Funksie

❮ MySQL-funksies

Voorbeeld

Onttrek 'n substring uit 'n string (begin by posisie 5, onttrek 3 karakters):

SELECT SUBSTR("SQL Tutorial", 5, 3) AS ExtractString;

Definisie en gebruik

Die SUBSTR()-funksie onttrek 'n substring uit 'n string (begin by enige posisie).

Let wel: Die SUBSTR()- en MID()- funksies is gelyk aan die SUBSTRING()- funksie.

Sintaksis

SUBSTR(string, start, length)

OF:

SUBSTR(string FROM start FOR length)

Parameterwaardes

Parameter Description
string Required. The string to extract from
start Required. The start position. Can be both a positive or negative number. If it is a positive number, this function extracts from the beginning of the string. If it is a negative number, this function extracts from the end of the string
length Optional. The number of characters to extract. If omitted, the whole string will be returned (from the start position)

Tegniese besonderhede

Werk in: Van MySQL 4.0

Meer voorbeelde

Voorbeeld

Onttrek 'n substring uit die teks in 'n kolom (begin by posisie 2, onttrek 5 karakters):

SELECT SUBSTR(CustomerName, 2, 5) AS ExtractString
FROM Customers;

Voorbeeld

Onttrek 'n substring uit 'n string (begin van die einde, by posisie -5, onttrek 5 karakters):

SELECT SUBSTR("SQL Tutorial", -5, 5) AS ExtractString;

❮ MySQL-funksies