0

I need to search hastag from posts but they are in post_text column

SELECT * FROM posts WHERE post_text = #hashtag

post tex column content example:

text here #hashtag text here

I have a hashtag page to get clicked hastag via get, but How can I do it because hashtag is inside text?

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

1 Answers1

0

You can use like in the where clause:

where post_text like concat('%', ?, '%')

The ? is a placeholder for a parameter passed into the query.

If you just want one value in particular:

where post_text like '%#hashtag%'
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786