How to Remove Content After Semicolon in PostgreSQL Field
In PostgreSQL, you can utilize the substring function to remove content after a semicolon (';') in a specific field. Here's an illustrative example:
UPDATE your_table
SET your_column = substring(your_column from '^([^;]+)')
WHERE your_column LIKE '%;%';
This example assumes you're targeting the your_column field and want to remove content solely after the semicolon. The substring function's argument '^([^;]+)' matches content starting with any character before the semicolon. The WHERE clause's LIKE '%;%' filters out fields containing a semicolon.
Remember to back up your data before executing this update statement to prevent accidental deletions.
原文地址: https://www.cveoy.top/t/topic/ejOu 著作权归作者所有。请勿转载和采集!