Remove or Trim First or Last Few Characters in MySQL Database with SQL Hủy bỏ hoặc Trim Nhân vật đầu tiên hoặc ít Lần trong cơ sở dữ liệu MySQL với SQL
Another useful string function in MySQL database is TRIM() which will return a text string after removing the matching leading or trailing characters, also known as prefixes or suffixes. Một chuỗi chức năng hữu ích trong cơ sở dữ liệu MySQL là Trim () mà sẽ trả về một chuỗi văn bản sau khi loại bỏ các kết hợp hàng đầu hoặc dấu ký tự, còn được gọi là tiền tố hoặc hậu tố. It's been described by MySQL reference as function that returns the string str with all remstr prefixes or suffixes removed. Nó được mô tả bởi MySQL tham chiếu là chức năng mà sẽ trả về chuỗi str với tất cả các tiền tố hậu tố remstr hoặc gỡ bỏ. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. Nếu không có specifiers CẢ, CÔNG, hoặc dấu được cho, BOTH là giả định. remstr is optional and, if not specified, spaces are removed. remstr là tùy chọn, và nếu không được chỉ định, không gian được gỡ bỏ.
Syntax of TRIM(): Cú pháp của Trim ():
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str) Trim ([(BOTH | CÔNG | dấu) [remstr] FROM] str), TRIM ([remstr FROM] str)
For example: Ví dụ:
SELECT TRIM(' bar '); SELECT TRIM ( 'bar');
will return 'bar' (spaces dropped). sẽ trở lại 'bar' (không gian bị bỏ).
SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx'); SELECT TRIM (CÔNG 'x' FROM 'xxxbarxxx');
will return 'barxxx' (only leading x characters is removed). sẽ trở lại 'barxxx' (chỉ dẫn x nhân vật được lấy ra).
SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx'); SELECT TRIM (xxxbarxxx TỪ 'CẢ' x '');
will return 'bar' (leading and trailing xs is dropped). sẽ trở lại 'bar' (hàng đầu và dấu xs là bị bỏ).
SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz'); SELECT TRIM (dấu 'xyz' FROM 'barxxyz');
will return 'barx' (trailing xyz is cleared). sẽ trở lại 'Barx' (dấu xyz là xóa).
This function is multi-byte safe. Chức năng này là đa-byte an toàn. And it can also be used with other SQL command such as UPDATE to perform modification update directly on database table data with SQL statements using tool such as phpMyAdmin. Và nó cũng có thể được sử dụng với lệnh SQL khác như UPDATE để thực hiện các sửa đổi cập nhật trực tiếp trên bảng dữ liệu với cơ sở dữ liệu SQL bằng cách sử dụng công cụ như phpMyAdmin.
IMPORTANT : The page is machine translated and provided "as is" without warranty. Quan trọng: Sửa là máy dịch và cung cấp "như là" không có bảo hành. Machine translation may be difficult to understand. Máy dịch thuật có thể khó hiểu. Please refer to Vui lòng tham khảo original English article bản gốc tiếng Anh bài viết whenever possible. bất cứ khi nào có thể.
Related Articles Bài viết liên quan
- How to Find and Replace Text in MySQL Database using SQL Làm thế nào để Tìm và Thay thế văn bản trong cơ sở dữ liệu MySQL sử dụng SQL
- Check and Optimize MySQL Database Automatically with Crontab/Cron Kiểm tra và Tối ưu hóa cơ sở dữ liệu MySQL Tự động với Crontab / định kỳ
- MySQL Database Performance Tuning Best Practices Video Tutorial Cơ sở dữ liệu MySQL Performance Tuning Best Practices Video Tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Enable Logging of Slow Queries (Slow Query Log) trong cơ sở dữ liệu MySQL
- How to Remove and Drop Datafiles from Tablespace in Oracle Database Làm thế nào để Hủy bỏ và Thả Datafiles từ tablespace trong Oracle Database
- Uninstall and Remove Multiple Database Instances of Microsoft SQL Server 2005 Gỡ bỏ và Hủy bỏ Multiple Instances Cơ sở dữ liệu của Microsoft SQL Server 2005
- How to Escape Characters in Oracle PL/SQL Queries Làm thế nào để thoát hiểm Nhân vật trong Oracle PL / SQL Queries
- Change and Reset MySQL root Password Thay đổi và Thiết lập lại mật khẩu root MySQL
- Change or Set MySQL Long Query Time Value for log-slow-queries Thay đổi hoặc Set MySQL Long Query Time giá trị gia tăng cho log-slow-queries
- WordPress MySQL SQL Query Error in WPDB Class WordPress MySQL vấn SQL Error in WPDB Class









































