I have two tables, one of which refers to parents, one of which refers to children.
Parent_ID | Parent_Name | Parent_Contact |
---|
And
Child_ID | Child_Name | Childs_parent |
---|
The Childs_Parent field is identical to the Parent_ID table
I want to run a query that will return me with this table, where each parent can have multiple children
Parent_name | Parent_Contact | Child_Name |
---|
I know this might sound simple to a lot of people on here, but I'm fairly new to using SQL in base, and having looked at multiple tutorials and help given to other people I'm really struggling to work this out for myself.
Thanks to comments, I have succeeded in getting the table to return the output in the table above, however as it stands, I have one table with multiple outputs for the same table.
I now have
Parent_name | Parent_Contact | Child_Name |
---|---|---|
Parent_1 | Info | Child_1 |
Parent_1 | Info | Child_2 |
I would like to get to
Parent_name | Parent_Contact | Child_Name |
---|---|---|
Parent_1 | Info | Child_1, Child_2 |
I have tried to use group by to achieve this, however I keep coming up with the following error
Not in aggregate function or group by clause: org.hsqldb.Expression@1186c88
I've tried this as both GROUP BY "parent" and Group by "parent_communication"."parent"
Try the following query (you may have to adapt table and field names:
You don't need an IF statement but a WHERE clause (or, with other SQL engines, a "LEFT JOIN". See also https://help.libreoffice.org/latest/ro/text/sdatabase/02010101.html