Hey guys,

I am having some difficulties regarding a select query logic.
Then I have a table with products and it has a column -> submodel with all kind of data in it.

3bcf9a8dac9e8218c88209198e26a7e5

What I want to achieve is to STRIP (with REGEXP?) all the strings starting with ( and ending with ) and then GROUP all X5 for example and instead of 7 X5's I want to have only 1.

Is this possible directly in MySQL ? The ideea is that I cannot clean the column because the data is used in other places also.

Got it solved :)

SELECT CONCAT(SUBSTRING_INDEX(i.submodel, '(', 1), '', SUBSTRING_INDEX(i.submodel, ')', -1)) AS model FROM products.items as i
    WHERE i.vendor_name LIKE '%(Product_SH)'
GROUP BY 1

f3a468a094655ec9d09f858762daffea

Member Avatar
diafol

My solution:

SELECT SUBSTRING_INDEX(`id`,'(',1) AS groups FROM `table` WHERE `id` LIKE 'x%(%)' GROUP BY groups

Never have known about this simple LIKE usage in this form! Great input diafol!!!