Q:

Find items in 3 or less levels CASE WHEN

I have this code where I want to go trough 3 levels and it doesn't seem to work if there are only 2 or 1 levels! What's wrong with my query?    
select lvl1.category_id AS l1, lvl1.parent_id AS l1, lvl1.title AS l1, 
           lvl2.category_id AS l2, lvl2.parent_id AS l2, lvl2.title AS l2
             ,
           lvl3.category_id AS l3, lvl3.parent_id AS l3, lvl3.title AS l3

    from category AS lvl1

    LEFT JOIN category AS lvl2
    ON lvl2.parent_id=lvl1.category_id

    LEFT JOIN category AS lvl3
    ON lvl2.category_id=lvl3.parent_id

    WHERE CASE WHEN lvl3.category_id='84' 
           THEN lvl3.category_id='84' ELSE (
                                                         CASE WHEN lvl3.category_id!='84' 
                                                         AND lvl2.category_id='84' 
                                                         THEN lvl2.category_id='84' 
                                                         ELSE (
                                                                  CASE WHEN lvl2.category_id!='84' 
                                                                  AND lvl1.category_id='84' 
                                                                  THEN lvl1.category_id='84' 
                                                                  END
                                                                )  
                                                          END 
                                                        )
            END

A:

As i got -1 already and it still will hit my stats will post answer that worked for me:
SELECT L1.category_id AS step1, L2.category_id AS step2, L3.category_id AS step3 , L1.title AS title1, L2.title AS title2, L3.title AS title3

FROM nordigen_category AS L1

LEFT JOIN nordigen_category AS L2
ON L2.category_id=L1.parent_id

LEFT JOIN nordigen_category AS L3
ON L2.parent_id=L3.category_id

WHERE L1.category_id='84'

Less code and does what i want on every LVL.

