gpt4 book ai didi

php - mysql中的逗号分隔值

转载 作者:行者123 更新时间:2023-11-30 22:13:29 26 4
gpt4 key购买 nike

在 Code Igniter 中从 MySQL 检索数据..

目前我的查询是这样的:

SELECT `gs_team_members`.`team_id`, 
`gs_users`.*
FROM (`gs_team_members`)
JOIN `gs_users`
ON `gs_users`.`id` = `gs_team_members`.`member_id`
JOIN `gs_user_privileges`
ON `gs_user_privileges`.`user_id` = `gs_users`.`id`
WHERE `gs_users`.`user_type` = 'member'
AND `gs_users`.`id` != '4'
AND `gs_user_privileges`.`privilege_id` = 7
AND FIND_IN_SET('19', submenu_previlege)
AND `gs_team_members`.`team_id` IN ('1', '2')
AND `team_id` = '2'
GROUP BY `gs_users`.`name`
ORDER BY `gs_users`.`name` ASC;

gs_team_members.team_id=1(意味着只有一个数字 ID)时工作正常。我希望它适用于 gs_team_members.team_id=1,2(表示多个逗号分隔的 ID)

最佳答案

这是一个例子..请试试这个

SELECT * FROM user where FIND_IN_SET(user_id, ('1,36,37'))

关于php - mysql中的逗号分隔值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39262706/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com