Get most frequent top 10 items found in a HTML column using Count

后端 未结 3 1306
南方客
南方客 2021-01-14 09:45

I have a bit of a messy query to try figure out.

I have a column called "meta_value" and in that I have some HTML data such as:



        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-14 10:14

    Depending on how frequently you need to perform this and the size of the dataset, I would probably extract this data out in to a new table. I would create a table with pk, card_name (unique), count and then write a command in the application to iterate over the existing data to parse the out the names from the tag bodies or the data-name attribute in the html and create the row or update the count in the row, and then make the change in the application to make sure that column gets updated whenever meta_value changes.

    Doing it this way and just sorting based on the count field will be more performant when for this specific lookup, but it will also make this query still be valid should the structure of your html ever change. It also allows for you at add other properties to these items

提交回复
热议问题