I think you need to break it apart a piece at a time. First, break apart the string bases on the SQL keywords (like "select", "from", "where" "group by", "sort by", etc). Once you have everything that is between "select" and "from", you should be able to pick that apart by the commas.
Never ascribe to malice that which can be adequately explained by stupidity.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35256
7
posted
1
I bet at least one of the standard Java parser packages (Antlr, JavaCC, SableCC) comes with a predefined grammar for SQL.