I need to get all columns and all tables from an SQL statement, let's say:
SELECT u.id, u.name FROM table1 as t1 LEFT JOIN table2 as t2 ON t2.id=t1.id INNER JOIN table3 as t3 ON t3.id=t1.id WHERE t1.id=1
The output needs to be:
Columns[] = { {"u","id"}, {"u","name"} }
Tables[] = { {"t1","table1"}, {"t2","table2"}, {"t3","table3"} }
I tried the following but i just get the two first table names
^SELECT\s*.*\s*FROM\s*([a-z_]*).*\sJOIN\s*([a-z_]*).*$