How to get multiple records against one record based on relation?

前端 未结 8 725
遇见更好的自我
遇见更好的自我 2020-11-29 09:11

I have two tables Organisation and Employee having one to many relation i.e one organisation can have multiple employees. Now I want to select all information of a particula

相关标签:
8条回答
  • 2020-11-29 09:23

    If you use Oracle you can create a PL/SQL function you can use in your query that accepts an organization_id as input, and returns the first name of all employees belonging to that org as a string. For example:-

    select
       o.org_id,
       o.org_address,
       o.org_otherdetails,
       org_employees( o.org_id ) as org_employees
    from
       organization o
    
    0 讨论(0)
  • 2020-11-29 09:30

    The short answer is "no".

    As noted in other answers, there are vendor-specific ways to achieve this result, but there is no pure SQL solution which works in one query.

    sorry about that :(

    Presumably one of the vendor specific solutions will work for you?

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