If you have query requirements, it is not suitable to store this thing in serialized form. Create another association table. In your example, it is a hobby table. It needs to include at least two fields: user ID and hobby. Search When you go to this table to search, then deduplicate the user ID to get the result you want, and then use this result to go to the user table to perform a select...in query
There is already a problem with your design. This correspondence requires three tables. The first one用户表(uid), uid as related field The second one兴趣表(hobby), hobby_idas related field The third one用户兴趣表(uid_hobby) The two fields uid, hobby_id can be related Get up. Which hobbies does a certain user have? OK, your requirement is 用户在前台搜索同样爱好的会员 The ID of football is 1 so the following statement. select uid from uid_hobby where hobby_id = 1 You can query all members who like football (including yourself) Finally, I suggest like Except for the left prefix, no other indexing will be used, full table scan + matching, extremely efficient Low.
If you have query requirements, it is not suitable to store this thing in serialized form. Create another association table. In your example, it is a hobby table. It needs to include at least two fields: user ID and hobby. Search When you go to this table to search, then deduplicate the user ID to get the result you want, and then use this result to go to the user table to perform a select...in query
There is already a problem with your design. This correspondence requires three tables.
The first one
用户表(uid)
,uid
as related fieldThe second one
兴趣表(hobby)
,hobby_id
as related fieldThe third one
用户兴趣表(uid_hobby)
The two fields uid, hobby_id can be related Get up. Which hobbies does a certain user have?OK, your requirement is
用户在前台搜索同样爱好的会员
The ID of football is 1
so the following statement.
select uid from uid_hobby where hobby_id = 1
You can query all members who like football (including yourself)Finally, I suggest
like
Except for the left prefix, no other indexing will be used, full table scan + matching, extremely efficient Low.mysql
find_in_set