简体   繁体   中英

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'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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