显示数据库中的主题标签

I have a problem, namely I want to display hashtags from such table "posts":

| id | author |   hashtags   |
|:------------|-------------:|
|  1 |  aaaa  | #aaa, #bbbb  | etc...
|  2 |  bbbb  | #ccc, #addd  |
|  3 |  cccc  | #aee, #ffff  |

The problem is that I would like to get something like this (only those records):

When I write a: #aaa, #addd, #aee
When I write b: #bbbb
etc...

How do I get the effect that only those hashtags that start with a letter (even in the same field) appear to me? I was thinking about regular expressions. Thanks in advance for any help.

You need to make a couple of changes:

  • Move hashtags columns to a new table and store different hashtags in different rows (with post id as foreign key) i.e. normalize the table
  • use LIKE operator to query on the new table, e.g.

    SELECT hashtag
    FROM post_hashtag
    WHERE post_id = <id>
    AND hashtag LIKE '%#a%';`