我按照我所做的二进制文件运行以下脚本来获取左侧和右侧
脚本
select a.ID,a.Node,a.direction,
a.Reference_ID,
a.Recommended_By
from
members a
JOIN
members b
ON
a.Node LIKE CONCAT('%(',b.ID,')%')
Where b.ID = 2
order by b.id,a.Recommended_By'
结果
**ID** **Node** **Direction** **Reference** **Recommended_By**
4 (2)(1) Left reem1 2
6 (2)(1) Right nevine1 2
9 (4)(2)(1) Left ghada1 4
11 (4)(2)(1) Right dina2 4
12 (6)(2)(1) Left amani2 6
13 (6)(2)(1) Right aulla2 6
18 (9)(4)(2)(1) Left amani3 9
19 (9)(4)(2)(1) Right dina3 9
我需要把CASE语句左右作为列,但我需要它像:
**ID** **Node** **Left** **Right** **Recommended_By**
4 (2)(1) reem1 2
6 (2)(1) nevine1 2
9 (4)(2)(1) ghada1 4
11 (4)(2)(1) dina2 4
前两个记录要按左右排序,但其余记录按照recommended_By进行排序