split up databse query