ÄÚÈÝtable: id name parentid 1 aaa null 14 bbb 1 47 ccc 14 72 ddd 47
ÎÊÌ⣺
ÒÑÖª¼Ç¼ id=72,name='ddd',parentid=47 ÒªÇóÓÃÒ»ÌõsqlÓï¾ä»ñµÃËùÓбí¼Ç¼¡£ --ÊÇÕâÑùÂð£¿ÊÇÕâÑùµÄ»°£¬Ò²¾Í߯¼òµ¥ÁË£¡ select * from table where id=72 and name='ddd' and parentid=47; ûÃ÷°×
select * from tb ? Èç¹ûÊÇ2005,¿ÉÒÔ,ÄãÕÒСPÁºÐ´. Èç¹ûÊÇoracleÒ²¿ÉÒÔÕâÑùдÂ𣿠²»ÖªµÀ. BOM½á¹¹ insert into @t_level select @id select @id = pid from tb where id = @id and pid is not null ÕâÓеãÔÎ ÔõôÓÐ2¸öselect ? SQL code: drop table test1; drop table test2; drop table test3;
create table test1(id int, name varchar(20), parentid int); insert into test1(id, name, parentid) values(1,'luoyoumou1', 2) insert into test1(id, name, parentid) values(72,'ddd', 47) create table test2(id int, name varchar(20), parentid int); insert into test2(id, name, parentid) values(2,'luoyoumou2', 3) insert into test2(id, nam