create a single sql builder function to handle article queries