How to find in a MySQL database?:
# Some title
(In a text field most of the titles are:
## Some title.
But there are some mistakes with only one #. How can I find them in a big database?. I know that they are only in the field text_post)
I could find that it could be something like:
SELECT * FROM blog
WHERE text_post LIKE '%#%'
But, how can I find when there is only one # and not two?
If I understand, it is not possible to use regex here. Is that right?
Add an extract clause to eliminate the double ##.
SELECT *
FROM blog
WHERE (text_post LIKE '%#%' AND text_post NOT LIKE '%##%')
^ - Beginning of line
# - hashtag
[^#] - Any character other than hashtag
| - OR operator
$ - End of line
select *
from blog
where text_post rlike '^#([^#]|$)'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With