0

i'm trying to convert this MsSQL to MySQL any idea how this can be done?

WITH Hierarchy(id, ciid1, name, parent, myLevel)
     AS (SELECT id,
                ciid1,
                name,
                parent,
                0 AS myLevel
         FROM   cities_new c
         WHERE  c.id = 2222
         UNION ALL
         SELECT c.id,
                c.ciid1,
                c.name,
                c.parent,
                ch.myLevel + 1
         FROM   cities_new c
                INNER JOIN Hierarchy ch
                  ON c.parent = ch.ciid1)
SELECT count(id) AS total
FROM   hotels_new
WHERE  id NOT IN( 69912, 70717, 75347 )
       AND ciid IN(SELECT id
                   FROM   Hierarchy) 
Martin Smith
  • 438,706
  • 87
  • 741
  • 845
Zaphord
  • 1
  • 1

0 Answers0