我陷入了mysql查询。我有一个员工表,其字段是id,name,bossid和bossid是员工的父ID。
我如何编写查询以此格式打印数据
id name boss
1 rajesh rajesh
2 vijay rajesh
3 ravi vijay
答案 0 :(得分:2)
def my_calc(my_series, func=max):
if not func in {'min', 'max'}:
raise ValueError('{} is not a valid method name!'.format(func))
return getattr(my_series.rolling(...), func)()
foo = my_calc(some_series, 'min')
bar = my_calc(some_series, 'max')
答案 1 :(得分:1)
只需加入桌子:
Select t1.id as id
, t1.name as Name
, t2.name as boss
from employee t1
join employee t2
on t1.bossid = t2.id