How to get a substring from a MYSQL table TEXTFIELD -
assume db structure is
table1 - id, field1
and sample entry is
1 <div class="image" data-content="contact"><img style="margin: 0px auto;display: table;" src="link" alt="contact" title=""></div>
now trying value link under src tag. tried useing regex, search none of them working correctly.
select * table1 field1 between 'src' , 'alt';
and,
select substring_index(substring_index(field1, 'src=', -1), 'alt', 1) table1
you can use below command
select substring(@str, charindex('src', @str)+5 , (charindex('alt',@str)+5) - (charindex('src', @str) + len('alt'))-9) table1
Comments
Post a Comment