funzione SQL MID ()
La funzione MID ()
funzione MID () viene utilizzato per estrarre caratteri da un campo di testo.
SQL MID () sintassi
SELECT MID(column_name,start[,length]) FROM table_name;
参数 | 描述 |
---|---|
column_name | 必需。要提取字符的字段。 |
start | 必需。规定开始位置(起始值是 1)。 |
length | 可选。要返回的字符数。如果省略,则 MID() 函数返回剩余文本。 |
Il database demo
In questo tutorial, useremo database di esempio w3big.
Il seguente è un selezionati "siti web" dati della tabella:
+----+--------------+---------------------------+-------+---------+ | id | name | url | alexa | country | +----+--------------+---------------------------+-------+---------+ | 1 | Google | https://www.google.cm/ | 1 | USA | | 2 | 淘宝 | https://www.taobao.com/ | 13 | CN | | 3 | 本教程 | http://www.w3big.com/ | 4689 | CN | | 4 | 微博 | http://weibo.com/ | 20 | CN | | 5 | Facebook | https://www.facebook.com/ | 3 | USA | | 7 | stackoverflow | http://stackoverflow.com/ | 0 | IND | +----+---------------+---------------------------+-------+---------+
SQL MID () esempi
La seguente istruzione SQL per estrarre i primi quattro caratteri dalla colonna "siti web" tabella "nome":
Esempi
SELECT MID(name,1,4) AS ShortTitle
FROM Websites;
FROM Websites;
Eseguire SQL sopra i risultati di uscita sono i seguenti: