i have table this:
--primary id---office id---- |----1-------|---10--------| |----2-------|---10--------| |----3-------|---20--------| |----4-------|---10--------| |----5-------|---20--------| ---------------------------- i want object/array this:
array = array( "10" => array( "primary id" => 1, "primary id" => 2, "primary id" => 4 ), "20" => array( "primary id" => 3, "primary id" => 5 ) ) my query be:
select * table order office id is there better query case?
there simple , small method creating array above?
edit: using sql server this... sadly no group_concat etc... ):
thanks!
its better use listagg function . i.e.
select office id, listagg(primary id, ', ') table group office id order office id once result of above sql, can tokenise each row delimiter ',' , put tokenised data in array.
Comments
Post a Comment