Regarding the two query statements of a single mysql table, in tab1, FID is the parent column ID. for example, if fid of Yichang Wuhan is 1, it is now known that AID in tab1 is 3, how can I query table Tab1 to obtain the tongji field in Hubei province? how can I check whether the tongji field in the parent column of AID is 3 ., SQLcodeSELECTt1.t about two query statements for a single mysql table
,,
In tab1, FID is the parent column ID. for example, if the fid of Yichang Wuhan is 1, it is now known that AID in tab1 is 3, how can I query table Tab1 to obtain the tongji field in Hubei province? how can I check whether the tongji field in the parent column of AID is 3.
------ Solution --------------------
SQL code
SELECT t1.tongji FROM tab1 t1 left join tab1 t2 ON t1.AID = t2.FAID WHERE t2.AID = 3
------ Solution --------------------
Query the tongji field in Hubei province:
SELECT tongji FROM Tab1 where area = 'hubei'
Query the tongji field in the parent column of aid 3.
SELECT tongji FROM Tab1 WHERE aid IN (SELECT faid FROM Tab1 WHERE aid = 3)