1.查省 SELECT * FROM china WHERE china.Pid=0 2.查市 SELECT * FROM chinaWHERE china.Pid=330000 3.查区 SELECT * FROM china WHERE china.Pid = 330100 4.Mysql脚本 DROP TABLE IF EXISTS `china`; CREATE TABLE `china` ( `Id` INT(11) NOT NULL, `Name` VARCHAR(40) DEFAULT NULL, `Pid` INT(11) DEFAULT NULL, PRIMARY KEY (`Id`), KEY `FK_CHINA_REFERENCE_CHINA` (`Pid`), CONSTRAINT `FK_CHINA_REFERENCE_CHINA` FOREIGN KEY (`Pid`) REFERENCES `china` (`Id`) ) ENGINE=INNODB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of china -- ----------------------------
sql下载