Fungsi
MySQL TRIM() digunakan untuk mengalih keluar akhiran, awalan atau kedua-duanya daripada rentetan. Prinsip kerja fungsi TRIM() boleh difahami melalui sintaksnya −
TRIM([{BOTH | LEADING | TRAILING} [str_to_remove] FROM] string)
Di sini, parameter
Di sini, parameter
mysql> Select TRIM(BOTH '0' FROM '0100'); +----------------------------+ | TRIM(BOTH '0' FROM '0100') | +----------------------------+ | 1 | +----------------------------+ 1 row in set (0.00 sec) mysql> Select TRIM(BOTH '**' from '**tutorialspoint.com**'); +------------------------------------------------+ | TRIM(BOTH '**' from '**tutorialspoint.com**') | +------------------------------------------------+ | tutorialspoint.com | +------------------------------------------------+ 1 row in set (0.00 sec) mysql> Select TRIM(Trailing '**' from '**tutorialspoint.com**'); +----------------------------------------------------+ | TRIM(Trailing '**' from '**tutorialspoint.com**') | +----------------------------------------------------+ | **tutorialspoint.com | +----------------------------------------------------+ 1 row in set (0.00 sec) mysql> Select TRIM(Leading '**' from '**tutorialspoint.com**'); +---------------------------------------------------+ | TRIM(Leading '**' from '**tutorialspoint.com**') | +---------------------------------------------------+ | tutorialspoint.com** | +---------------------------------------------------+ 1 row in set (0.00 sec)
Atas ialah kandungan terperinci Apakah tujuan fungsi MySQL TRIM()?. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!