This content has been marked as final. Show 8 replies
whats a geberic statement
whats a bane?
can you give an example of such a statement, and what is the expected output?
SELECT A.X, B.Y FROM A INNER JOIN B ON A.T=B.T WHERE A='2' AND B=2
this style except for the fact that i do not know previosly how many columns i have, how many inner join i have, how many and or clause i have, how many tables i have.
Thanks in advance for your attention
I suggest you you look into using a dedicated SQL parser. Regexes and SQL make a very poor fit.
I believe in Reg Exp! ; )
If you insist it should be something like:
"SELECT ([A-Z0-9_]+)[.][A-Z0-9_]+(,([A-Z0-9_]+)[.][A-Z0-9_]+)* FROM (([A-Z0-9_]+)[.][A-Z0-9_]+) INNER JOIN (([A-Z0-9_]+)[.][A-Z0-9_]+) ON .+" plus spaces etc... Yes it's for this kind of statements only.
But SQL parser is better because anyway you'll need to at least remove duplicates from founded names...
Don't encourage him, next he will find that doesn't work for subselects and try to fix it up. Like uncle_alice said, it ain't gonna work.
I agree this is wrong way for whole SQL but in some cases if all statements are just like this then why not...
If all you've got is a hammer, eventually everything starts to look like nails.