0

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.

Edited by Szabi Zsoldos

2
Contributors
3
Replies
19
Views
3 Years
Discussion Span
Last Post by Szabi Zsoldos
0

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

Edited by Szabi Zsoldos

1

My solution:

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

Edited by diafol

0

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

Edited by Szabi Zsoldos

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.