Select a separate list of substrings from one of the fields in the MySQL table

I have lines like

  • [ISSUE] This is an example of a problem.
  • [WEBSITE] Website Error
  • Note that this line does not contain anything inside square brackets
  • [WEBSITE] Another mistake on the website
  • [TRACKER] This is not alive!
  • Some lines will have them in the [middle], but I do not want them

etc..

Suppose a field is called a Title and a table is called Problems. All items in this column begin with a line in square brackets. There is no definitive list of which words can appear in square brackets. There are also no length restrictions. I do not need to receive it if the field does not start with such a line.

I want to get a word inside a pair of square brackets and get a unique list of these words.

[XYZ] s. , :

  • TRACKER

. [ ] ​​ , . , MySQL. , ?

+3
3

:

select distinct `Match` from (SELECT MID(Title,instr(Title,'[') + 1,instr(Title,']') - instr(Title,'[') -1) As 'New_Title'
FROM Issues u Where instr(Title,'[') > 0 AND instr(Title,']') > instr((Title),'[')) tbl

, , , .

+1

, , Title. , , , . , .

.

SELECT Issue, Website, Tracker FROM `Issues` Where distinct(Title) LIKE '[SOMETHING]%'
+1

SELECT is different (in the case where the REGEXP header is' ^ [[] 'then concat (substring_index (title,'] ​​', 1),'] ') end) as the FROM header test.issue i where the REGEXP header is' ^ [[] ';

0
source

Source: https://habr.com/ru/post/1764863/


All Articles