Satish Satish - 2 years ago 101
MySQL Question

Generic MySQL Query for Trimming Column Data

I have a Table in which one of the column contains data as follows:

file1 (
file2 (
file3 (
file4 (

I want to trim off the text from Opening parenthesis. After trimming, the Updated data should be as follows:


Since the Records are in Hundreds, is there a Generic way to Trim off the unwanted text? How the Query is written in MySQL

Answer Source

Your SQL query could be like this:

         UPDATE your_table_here SET file_name = RTRIM(SUBSTRING(file_name, 1, LOCATE('(', file_name)) - 1 );

Just replace file_name and your_table

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download