Combine Query and Select Database to create directory loop

Combine Query and Select Database to create directory loop