SQL query C++ code (My first C++ application)
I found this code very difficult to understand, and I feel that I won't be alone. I can't refactor it (for the aforementioned reason) nevertheless some advice which you might find instructive:


Please use names which people will make sense of: column_name_list, opt, "F", opterr etc etc - this makes reading code very difficult.
formatting - please use good formatting it all makes a difference.
break things up into methods so that each method is doing only one thing.
Add better comments if things are not self-explanatory.


My two cents.