Adamhumbug Posted February 13, 2020 Share Posted February 13, 2020 I have an array that has comma sep values. I am wanting to run a select statement that includes a NOT IN function. SELECT user_firstname, user_lastname, user_id FROM ssm_user WHERE user_role_id = ? and where user_id NOT IN(?) Is this possible, oir does the ? just represent a literal string. If so do i need to convert the array to a string before running the above? Quote Link to comment https://forums.phpfreaks.com/topic/310027-prepared-statement-not-in-function/ Share on other sites More sharing options...
Barand Posted February 13, 2020 Share Posted February 13, 2020 If there are are 10 values in your array then you need 10 placeholders i.e. NOT IN (?,?,?,?,?,?,?,?,?,?) then $stmt->execute( $yourarray ); Quote Link to comment https://forums.phpfreaks.com/topic/310027-prepared-statement-not-in-function/#findComment-1574256 Share on other sites More sharing options...
mac_gyver Posted February 13, 2020 Share Posted February 13, 2020 use (NOT) FIND_IN_SET(str,strlist). the strlist parameter can be supplied via a single prepared query place-holder. 1 Quote Link to comment https://forums.phpfreaks.com/topic/310027-prepared-statement-not-in-function/#findComment-1574260 Share on other sites More sharing options...
Barand Posted February 13, 2020 Share Posted February 13, 2020 I rarely use sets so I keep forgetting about the FIND_IN_SET() function Quote Link to comment https://forums.phpfreaks.com/topic/310027-prepared-statement-not-in-function/#findComment-1574261 Share on other sites More sharing options...
Adamhumbug Posted February 15, 2020 Author Share Posted February 15, 2020 A bit of working out here but that worked perfectly. Thank You Quote Link to comment https://forums.phpfreaks.com/topic/310027-prepared-statement-not-in-function/#findComment-1574298 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.