易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql 改个函数 - 其他数据库开发 / MySQL/Postgresql

create table treeNodes
  (
  id int primary key,
  nodename varchar(20),
  pid int
  );

CREATE FUNCTION `getChildLst`(rootId INT)
  RETURNS varchar(1000)
  BEGIN
  DECLARE sTemp VARCHAR(1000);
  DECLARE sTempChd VARCHAR(1000);
   
  SET sTemp = '$';
  SET sTempChd =cast(rootId as CHAR);
   
  WHILE sTempChd is not null DO
  SET sTemp = concat(sTemp,',',sTempChd);
  SELECT group_concat(id) INTO sTempChd from treeNodes where FIND_IN_SET(pid,sTempChd)>0;
  END WHILE;
  RETURN sTemp;
  END


这个是查出所有子节点id $,1,2,3,4,5,6,7
  我想要查出所有父辈节点id ,深度为10 (就是只查10个父辈节点),如果超过10个后面的就不查不来
  删除结果 '1','2','3','4'
 

  建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
  参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
   
  1. 你的 create table xxx .. 语句
  2. 你的 insert into xxx ... 语句
  3. 结果是什么样,(并给以简单的算法描述)
  4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
  &nbs


相关问答:

eclipse连接mysql数据库 - Java / Eclipse

先上错误
无法联接数据库
java.sql.SQLException: Before start of result set
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java: ......

mysql区没高手 - MS-SQL Server / 基础类

我觉得mysql和sqlserver有共同的地方:
有个问题是关于表的锁问题:
进程A 进程B
select * from user where id in lock share mode(共享锁)
&nb ......

一个mysql中关于in子查询的问题 - Java / Web 开发

SELECT * from alarms where id in (select resource_id from res_products where product=22)
这个语句在mysql中为什么不能执行?我的mysql数据库是5.0.27版本的!
如果实在不行那么该用个什么语句代替效率更高呢 ......

mysql 累加运算 - 其他数据库开发 / MySQL/Postgresql

sp 程序
delimiter //
create procedure ma()
begin
declare i int default 0;
while i<11 do
set i=i+1;
select i;
end while;
end //
delimiter ;
1+2+...+9+10
为什么这个程序无法实现累加效果
/ ......

mysql存储过程 - 其他数据库开发 / MySQL/Postgresql

在mysql存储过程中定义变量和参数时可有可无符号@,请问有@和没有@有什么区别?谢谢!

create procedure mypro()
begin
declare @temp int;
set @temp=3;
end //
创建这个存储过程的时候为什么会报错呢?
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号