I’m building a website with PHP & mySQL.
In my application, the categories of products are stored as hierarchy in DB.
I followed the approach of “Materialized path” (aka “Flat table Model”) & created a table like this :

Suppose I want to build a breadcrumb for items in category FLASH (category_id=8) :
ELECTRONICS -> PORTABLE ELECTRONICS -> MP3 PLAYERS -> FLASH
I wonder if I could get the line of ancestry from ‘FLASH’ IN CORRECT ORDER by this query:
Select * from category where category_ID in (1,6,7,8) ORDER BY '1,6,7,8'
What can be the correct replacement for :
ORDER BY '1,6,7,8'
? Thanks for all suggestions !
I found the answer my own !
The SQL string above can help me to sort ID by any predefined order : 1-6-7-8 or 1-8-7-6 or 6-1-8-7 or any thing else !