Query output with indentation

前端 未结 1 750
清歌不尽
清歌不尽 2021-01-26 02:17

I have table System

component | subcomponent  (foreign key with subsystem table)
----------+-------------
cpu       |  1
monitor   |
lcd       |
keybord   |
mouse            


        
相关标签:
1条回答
  • 2021-01-26 03:08

    It's possible using e.g. a left join and some of the string formatting functions:

    select ... as parent, '  -- ' || coalesce(..., '') as child
    from ... left join ... on ...
    

    You could also union things instead, etc. to get exactly what you requested.

    BUT you really ought to leave that up to the view, as already suggested.

    0 讨论(0)
提交回复
热议问题