我有下表:
ID | Keyword | Date
87NB | skill,love,hate,funny,very funny | 02/19/2004
27YV | funny,tiger,movie,king | 08/10/2014
92JK | sun,light,funny,baby | 06/27/2015
65TH | moon,cow,bird,car | 04/22/2017
从上表中,我想获得将“有趣”作为关键字的所有人的ID。结果将是
ID
87NB
27YV
92JK
答案 0 :(得分:1)
你可以使用split然后使用函数array_contains
select ID from yourtable where array_contains(split(Keyword, ","), "funny");
答案 1 :(得分:1)
select ID
from t
where find_in_set('funny',Keyword) > 0
;
+------+
| id |
+------+
| 87NB |
+------+
| 27YV |
+------+
| 92JK |
+------+