有一个试图 。是从表里取出的。
字段 : ss(父亲) xx(儿子)
值: aa cc
bb dd
ee
ff
gg hh
我想让CC、dd、hh和ee、ff变成一列。把有儿子的父亲单独列出来。请问要怎么写啊 ???
字段 : ss(父亲) xx(儿子)
值: aa cc
bb dd
ee
ff
gg hh
我想让CC、dd、hh和ee、ff变成一列。把有儿子的父亲单独列出来。请问要怎么写啊 ???
还是我理解能力有问题?
分两步:
1、取出没有儿子的父亲,这句SQL很显然:
select ss from view_name where xx is null
2、取出有父亲的儿子
select xx from view_name where ss is not null and xx is not null
最后,把上面的结果UNION ALL起来就是楼主想要的结果了。