mySQL | View with Union – no brackets

CREATE VIEW ratemyhouse.v (level, id, dsc) AS
(SELECT 1 as level, object_id as id, object_desc as dsc
FROM object
WHERE object_prt IS NULL)
UNION
(SELECT 2 as level, t2.object_id as id, t2.object_desc as dsc
FROM object t1
LEFT JOIN object t2 ON t2.object_prt = t1.object_id
WHERE t1.object_prt IS NULL
AND t2.object_desc <> ”)
UNION
(SELECT 3 as level, t3.object_id as id, t3.object_desc as dsc
FROM object t1
LEFT JOIN object t2 ON t2.object_prt = t1.object_id
LEFT JOIN object t3 ON t3.object_prt = t2.object_id
WHERE t1.object_prt IS NULL
AND t3.object_desc <> ”)

http://stackoverflow.com/questions/9941226/mysql-cannot-create-view-that-contains-union

mySQL | left join instead of recursive hierarchy

select * from (
(SELECT 1 as level, object_id as id, object_desc as dsc
FROM object
WHERE object_prt IS NULL)
UNION
(SELECT 2 as level, t2.object_id as id, t2.object_desc as dsc
FROM object t1
LEFT JOIN object t2 ON t2.object_prt = t1.object_id
WHERE t1.object_prt IS NULL
AND t2.object_desc <> ”)
UNION
(SELECT 3 as level, t3.object_id as id, t3.object_desc as dsc
FROM object t1
LEFT JOIN object t2 ON t2.object_prt = t1.object_id
LEFT JOIN object t3 ON t3.object_prt = t2.object_id
WHERE t1.object_prt IS NULL
AND t3.object_desc <> ”)
)
as combined;