当前位置: 动力学知识库 > 问答 > 编程问答 >

php - comma separated values in mysql in

问题描述:

Retrieving data from MySQL in Code Igniter..

Currently my query is this:

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;

Working fine when gs_team_members.team_id=1 (means only one numeric id). I want it to work for gs_team_members.team_id=1,2 (means multiple comma separated ids)

网友答案:

this is one example.. please try this one

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: