Query is : Select id, col2, col3, col4 From TableA Array should be as below: (1, 2 are id from TableA) %arry = ( 1 => {col2=>"abc", col3=>"def", col4=>"ghi"}, 2 => {col2=>"lmn", col3=>"opq", col4=>"rst"}, )