patternMinor
Fetch all words from column with like
Viewed 0 times
columnallwithwordsfetchlikefrom
Problem
I have a column with description and inside it can contain # value .
what I want is all the words searched from that column with #tag
This is my query
and this is what I get as output
and what I want is this output how to modify my query in order to get below output
what I want is all the words searched from that column with #tag
This is my query
SELECT description FROM photo where description like '%#aw%';and this is what I get as output
description
'nice place #awesome'
'my pc #awe'
' nice design #aw'
'my table #awesomedatabase'and what I want is this output how to modify my query in order to get below output
description
#awesome
#awe
#aw
#awesomedatabaseSolution
You can use the INSTR function of MYSQL to find the starting position of the word matching your delimiter '%#aw%'. And then use sub string to fetch the word of your interest.
for eg. SELECT SUBSTR(description,INSTR (description,'#'))
FROM photo where description like '%#aw%';
The problem here though is that if the word is followed by anything, it will also be a part of your output. You will need to find the position of the immediate next 'blank space' and use it as the LEN parameter (the 3rd param in SUBSTR function).
for eg. SELECT SUBSTR(description,INSTR (description,'#'))
FROM photo where description like '%#aw%';
The problem here though is that if the word is followed by anything, it will also be a part of your output. You will need to find the position of the immediate next 'blank space' and use it as the LEN parameter (the 3rd param in SUBSTR function).
Context
StackExchange Database Administrators Q#77073, answer score: 3
Revisions (0)
No revisions yet.