I have a column called image_small for a table images which will have information like this:
image_small
/images/menu_items/148/5a13140f8ef4503f024d06231037c69e_medium.jpg
/images/menu_items/152/5a14444444444444424d06231037c69e_medium.jpg
...
I’d like to select out a the count of unique values for the menu item value (148) above (assume 148-400) on Mysql 5.1 using innodb so that output would be like:
val count
148 5
101 4
152 1
The integer values (148,101,152) don’t exist in a column and would rather not loop through.
Any ideas on how to do this? Would seem like would need to create a notion of a variable for the ‘148’ and then a group by but a little clueless.
thx
I’m supposing that all your paths have the same format.
It seems to work but I’m afraid about performance on large tables. Do some tests.
Could you add a field with this value? I think it would be better.