我试图命令MySQL在一行的配对总数中选择发言。 例如,如果表象......
id | dessert | choice
---------------------
1 | pie | apple pie, chocolate pie
2 | cake | chocolate cake, lemon cake, white chocolate cake, triple chocolate cake
3 | donut | frosted donut, chocolate donut, chocolate cream donut
......以及如果有人查询<代码>chocolate,结果应当命令:
dessert | matches
-----------------
cake | 3
donut | 2
pie | 1
However, I m struggling to make the query ordered like this. I ve looked at other examples here, but they seem overly complicated for what I guessed would be a fairly simple thing.
是否有直截了当的办法来做到这一点? 我对我的SQL说了新话,如果这是一个显而易见的问题,那么我会感到愤怒。
提前感谢你们的想法!
P.S. I m无法在本表中使用fulltext
,因此我可以按相关性来决定结果。