内容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