SQL avoids recursion. Today, a tangle problem is found in the development project. Modify the SQL code www.2cto.com CREATE TABLE PRO_TYPE (PRODUCTTYPEID INTEGER NOT NULL, PRODUCTTYPENAME VARCHAR2 (50) according to the parent and child classes) not null, parentid integer not null, STATUS VARCHAR2 (1) DEFAULT '1', createdate date default sysdate); comment on table PRO_TYPE IS 'product type table '; comment on column PRO_TYPE.PRODUCTTYPEID IS 'product type id'; comment on column PRO_TYPE.PRODUCTTYPENAME IS 'product type name'; COMMENT On column PRO_TYPE.PARENTID IS 'parent product type ID (0 IS the root node) '; comment on column PRO_TYPE.STATUS IS' status (0-disabled, 1-enabled )'; comment on column PRO_TYPE.CREATEDATE IS 'creation time'; alter table PRO_TYPE add constraint PK_PRO_TYPE primary key (PRODUCTTYPEID); goals to be achieved at www.2cto.com: use the parent ID or common ID to find the associated items of other tables. If the product type ID is the product parent class ID 1 0 2 0 3 1 4 2 If the structure in the database is the same, the parent-child relationship is divided, when writing SQL statements, you can select the parent class to find out the corresponding content of the subclass. How can this problem be solved. In this way: product Type ID product parent class ID 10 0 20 0 1003 10 2004 20 200401 200401 this way we use like '000000' when querying the class so that we can find all content under the sub-10 class and sub-class