I'm trying without success to solve this tricky point. I have a mysql table like the following:
Category Model Description
cat1 AAA Triple A
cat1/cat2 AAA Triple A
cat1/cat2 BBB Triple B
cat1 BBB Triple B
cat3 CCC Triple C
cat3/cat4/cat5 CCC Triple C
cat3/cat4 CCC Triple C
etc.
I would like to select rows with unique Model and "longest" Category. Basically I would like to obtain:
Category Model Description
cat1/cat2 AAA Triple A
cat1/cat2 BBB Triple B
cat3/cat4/cat5 CCC Triple C
Any hint?
Categoryout into another table that links each category to aModelin a one-to-many relationship. You would then avoid this problem entirely.