Assuming there is a sql script:
select *
from (
select col1 from test.test_a join test.test_a1 on a.col1 = a1.col1) a
left join test.test_b b
on a.col1 = b.col2
left join
test.test_c c
on b.col2 = c.col3
left jon
(select
col4
from
test.test_d) d
on c.col3 = d.col4
I am reading this question and tring to extract all TABLE NAMES after 'from
' or 'join
' in the script above using python.
The difficuty is I am processing the script line by line, but the table name and the key word may be NOT in the same line.
So how to extract such table names from the script? Any suggestion is appreciated.