Satish Satish - 8 months ago 33
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


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