我需要从SQL语句中获取所有列和所有表,比方说:
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
输出必须是:
Columns[] = { {"u","id"}, {"u","name"} }
Tables[] = { {"t1","table1"}, {"t2","table2"}, {"t3","table3"} }
我尝试了以下内容,但我只获得了两个第一个表名
^SELECT\s*.*\s*FROM\s*([a-z_]*).*\sJOIN\s*([a-z_]*).*$