是这个效果吧
http://code68.com/Admin/Index
要用到递归查询,easyUI有个child参数,
这样就是 无限极的 树结构了
你的表中pId应该对应上一级的id 这样才能说是正确的对应关系。这样子的话sql语句:
select first.cateName from first_cast as first where one.id=(select two.id from two_cast as two inner join third_cast as third where two.id = third.pId));
先二三级表建立关系,找的第二张表的内容,再跟第一级建立关系,找到第一张表的内容 。注:能否找到没试过,仅提供一个思路
大概就是这样
select f.cateName from third_cate t,second_cate s,first_cate f where t.pid=s.id and d.pid=f.id and t.id=??
这里利用连接查询即可,如果pid对应上一级id的话,我给的SQL如下
SELECT t.id,t.cateName,s.cateName,f.cateName FROM third_cate t
LEFT JOIN second_cate s ON t.pid = s.id
LEFT JOIN first_cate f ON s.pid = f.id ;
将三张表联合起来查询自己想要的字段,如下图,我只建了部分字段和数据,效果如下,希望能帮到你
楼上是就可以,但是你这种情况多数据量大的话,可以建立视图
不好意思我说的楼上被我顶了一下,到最上面去了