How to get the name of the flag field of the article in the corresponding table when querying mysql articles

The

scenario is: there is a flag field in my text table (news). Its type is the set collection, and the possible values are letters, such as "Agrappagh d". These letters correspond to a diyflag table with Chinese names corresponding to these letters. The two tables are as follows:

Article table news (where the flag field is the set collection type)

< table > < thead > < tr > < th > id < / th > < th > title < / th > < th > flag < / th > < / tr > < / thead > < tbody > < tr > < td > 1 < / td > < td > title 1 < / td > < td > a _ c < / td > < / tr > < tr > < td > 2 < / td > < td > title 2 < / td > < td > a td b < / td > < / tr > < tr > < td > 3 < / td > < td > title 3 < / td > < td > bline c < / td > < / tr > < / tbody > < / table >



property sheet diyflag

< table > < thead > < tr > < th > id < / th > < th > flag_value < / th > < th > flag_name < / th > < / tr > < / thead > < tbody > < tr > < td > 1 < / td > < td > a < / td > < td > headlines < / td > < / tr > < tr > < td > 2 < / td > < td > b < / td > < td > Select < / td > < / tr > < tr > < td > 3 < / td > < td > c < / td > < td > recommend < / td > < / tr > < / tbody > < / table > The structure of the

table is shown above, and what I want now is that the result of the query directly shows that the flag field is the corresponding Chinese name (such as headline, selected), rather than letters such as aforme b.
I would like to consult my brothers, thank you for your advice!

Oct.14,2021

how to put this? it is not recommended to perform operations in sql statements (the key is how a sql can get the results you want. I really don't know.
I have a compromise idea. Please refer to:

.
  1. take out the list data you need in the news table to form $news_list;
  2. array_column take out the flag of $news_list to form a $flag_list collection;
  3. Loop the $flag_list, array_merge ($new_flag_list, explode (',', $flags)) ) to form a new new_flag_list,. The values in this new_flag_list are all separate
  4. .
  5. array_unique ($new_flag_list) is removed, and flag_value in (new_flag_list) is used to query the data in the diyflag table according to the deduplicated result to form flag_value = > $flag_name key-value pair
  6. .
  7. Loop $new_list , replace abc
Menu