mysql - Return column names where they meet a specific value in sql -
i've user table has "access role" defined in table itself.
schema:
userid, username, access_1, access_2, access_3, .... access_10
here values access_columns 1 or 0
objective: need users , allowed accesses in 1 column 'access_allowed'.
userid, access_allowed 1, (access_1, access_3, access_4, ...) 2, (access_2, access_3, access_5, access_10, ...)
regards,
yugal
thanks strawberry... i've used concat_ws here... select userid, username, concat_ws(', ', if(access1 = 1 ,'access1', null), if(access2 = 1 ,'access2', null), if(access3 = 1 ,'access3', null), if(access4 = 1 ,'access4', null), . . if( accessn = 1 ,'accessn',null) access_allowed usertable
Comments
Post a Comment