gpt4 book ai didi

mysql - 删除mysql表中括号内的数据

转载 作者:行者123 更新时间:2023-11-29 21:21:53 25 4
gpt4 key购买 nike

我有一个 MySQL 表,其中的客户字段包含括号中的一些数据。例如——

客户

ABCDEFG Company, Inc. (Dallas, TX)
ABC Conglomerate International, Inc (New York, NY)

有没有办法使用 SQL 删除括号中的数据并保留公司名称?

最佳答案

假设,如果公司名称中有括号,则

查询

select 
replace(customer, concat('(',substring_index(customer, '(', -1)), '') as new_col_name
from your_table_name;

SQL Fiddle demo

关于mysql - 删除mysql表中括号内的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35685791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com