I have a listbox that a user can select multiple values from . each user selection is stored in db as string e.g. (1,4,5) . each number represents a listitem . the question how can I retrieve most selected items, say five most items via sql ?
Share
Given the option, it would be better to store the user selections in a more granular way, something like a table that just matches users with single selections. So if user 555 selected 1, 4, 5 the rows would be
Then finding out what gets selected the most would be a simple count. Otherwise you’re going to have to parse the ‘(1, 4, 5)’ which is going to be rather ugly. Usually not a good idea to store multiple values in a single column like that.