insert into node_tree(node_name,up_node_id,node_level) values('jx',null,'1'),('jx.webserver',1,'2'),('jx.webserver.nginx1', 2, '3'), ('jx.logserver', 1, '2')
select
node_tree1.id as 主表ID,
node_tree1.name as 主表名字,
node_tree2.name as 从表名字,
node_tree2.up_id as 从表上级ID
from node_tree1, node_tree2
where node_tree1.name='jx'
select
node_tree1.id as 主表ID,
node_tree1.node_name as 主表名字,
node_tree2.node_name as 从表名字,
node_tree2.up_node_id as 从表上级ID
from node_tree as node_tree1, node_tree as node_tree2
where node_tree1.node_name='jx'
字段:id ,name ,friend_id,hit_id,like_id关联:friend_id为A表id,hit_id为A表id
要求查询结果如下:
id ,name ,friend_id关联的name,hit_id关联的name,hit_id关联的name,like_id关联的name!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)