SELECT T3.ID,T3.NAME
FROM ZY_UNIT_WARD T1
LEFT JOIN XT_UNIT T2 ON T1.UNITID=T2.ID
LEFT JOIN zy_ward T3 ON T2.ID=T3.UNITID
WHERE T2.ID=8
SELECT T1.ID,T1.NAME FROM zy_ward T1,XT_UNIT T2,ZY_UNIT_WARD T3
WHERE T1.ID=T3.WARDID AND T2.ID=T3.UNITID
前者效率高,後者是取笛卡兒積,相當於二重循環,復雜度N^2,前者是hash匹配,復雜度LogN