sql - MySQL: how to select many results from linked table at one row to another? -


at first - im sql newbie, sorry (mbe typicall) question.

i have 2 table: table of organisations...

id_org    org_name 1         organiz1 2         organiz2 

and table of organization staff.

id_staff  staff_name   id_org 1         john         1 2         jack         1 3         sally        1 4         peter        1 5         andy         2 6         joe          2 

i want sql answer(two rows) this

1 organiz1 1 john 2 jack 3 sally 4 peter 2 organiz2 5 andy 6 joe 

and want each name or id of staff named staff_1_name(staff_2_name,staff_3_name) , staff_1_id. how can it?

 select o.id_org, o.org_name, group_concat(concat(s.id_staff, ' ', s.staff_name) order s.id_staff separator ' ')  organizations o, staff s  s.id_org = o.id_org  group id_org, org_name; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -