mysql - Get Values not in the second table using find_in_set -


i have 2 tables , need list of store_ids not in other table

businessunit table   user table storeid(varchar)     storeid(varchar) 1                    1,2 2                    3,4 3                    1,5 4                    4,6 7                    4 

how values of storeid 5,6 not present in business unit table present in user table? tried use several using find_in_set , nothing works.

use substring_index values csv field. since there can 6 ids in csv, need call once each position.

select u.storeid (     select substring_index(storeid, ',', 1) storeid     user     union     select substring_index(substring_index(storeid, ',', 2), ',', -1)     user     union     select substring_index(substring_index(storeid, ',', 3), ',', -1)     user     union     select substring_index(substring_index(storeid, ',', 4), ',', -1)     user     union     select substring_index(substring_index(storeid, ',', 5), ',', -1)     user     union     select substring_index(substring_index(storeid, ',', 6), ',', -1)     user) u left join businessunit b on u.storeid = b.storeid b.storeid null 

demo


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -