我正在尝试将此 MsSQL 转换为 MySQL 知道如何做到这一点吗?
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)