Fixed sql for selecting vocabularies.