split keywords for post php mysql

后端 未结 2 1591
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 15:09

i have one table store post id and it\'s tags like :

Post_id |  Tags
--------------------------------------
1       |  keyword1,keyword2,keyword3
         


        
2条回答
  •  忘掉有多难
    2020-11-28 15:41

    for each keyword, do

    insert into newtable (id, keyword) select id, 'aKeyword' from oldtable where oldtable.keywords like '%aKeyword%'
    

    if oldtable.keywords is just a VARCHAR, or

    insert into newtable (id, keyword) select id, 'aKeyword' from oldtable where FIND_IN_SET('aKeyword',keywords)>0
    

    if it's a SET type.

提交回复
热议问题