简体   繁体   English

在字符串的一部分中查找字符串/数组

[英]Finding a string / array in part of a string

This is an example of what my table consists of: 这是我的桌子组成的一个示例:

groupCanSee
1
1,2
-1,2

I have then got an array (detailing the groups that that member is a part of), which I have converted into a string - But could be left as an array. 然后,我得到了一个数组(详细说明了该成员所属的组),我将其转换为字符串-但可以保留为数组。

I have tried to use FIND_IN_SET(groupsCanSee, $usersGroups) - But the problem I am of course having, is that the FIND_IN_SET function, can only spot 1 part of a string (eg 1 in 1,2) but if I want it to be visible to groups 1 and 4 (FIND_IN_SET('1,4','1,2')) it will not work. 我尝试使用FIND_IN_SET(groupsCanSee, $usersGroups) -但是我当然遇到的问题是FIND_IN_SET函数只能发现字符串的1个部分(例如1,2中的1),但是如果我想要的话对组1和组4 (FIND_IN_SET('1,4','1,2'))可见(FIND_IN_SET('1,4','1,2'))将不起作用。

Does anyone have any suggestions on a workaround? 有人对解决方法有任何建议吗?

简单的布尔逻辑:

FIND_IN_SET(groupsCanSee, `1`) OR FIND_IN_SET(groupsCanSee, `4`)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM