Only records with column containing x word [closed]

0

I have a posting system done: the user makes the post and when it contains a # followed by a word, the word is automatically added in another column with a comma. Post example:

  

Good @Stackoverflow personal day, could you please help me?

Sample registration in the table:

  

id: 1, post: Good #Stackoverflow personal day, could you help me?, author: Raphael, hashtags: day, help

I'm just setting up a page to show only posts containing hashtag x.

I need a code that shows only the records containing the word x in the hashtags column.

Example: I need to show all the records that contain the good word in the hashtags column.

  

id: 1, post: Could you help me, anyway, #bom #dia !, author: Raphael, hashtags: help, good, day

     

id: 2, post: #Boa #Stackoverflow personal night, could you help me?, author: Raphael, hashtags: good night, help

     

id: 3, post: #Bom #fds staff @Stackoverflow, could you help me?, author: Raphael, hashtags: good, fds, help

Then the system will only show the records with id 1 and 3 because they contain the good word inside the hashtags column.

    
asked by anonymous 23.07.2017 / 03:38

1 answer

2

To search for a certain word, use the wildcard character:% (Percentage)

To search for the word, whether it is in the beginning, middle or end.

select * from NOMEDATABELA where hashtags like '%bom%'
    
23.07.2017 / 07:33