Made SQL generation in function create_feed more flexible.