This simple demo illustrates how to get table and columns involved in a select list item like this:
select sal.income + sal.bonus * emp.age + 5 as real_sal, emp.name as title from employee emp, salary sal where emp.id=sal.eid
What this demo do is tell you that in select list item:
sal.income + sal.bonus * emp.age + 5 as real_sal
columns been referenced are listed below:
salary.income salary.bonus employee.age
General SQL Parser can handle this well no matter how complex the select list item is. If combine this demo together with this demo: Visit SQL statement recursively, then it’s easy to get information such as which columns (with their respective tables) provide the data of the result set, no matter which set operation (union, minus) they are in, no matter how deeply embedded in select-clause subqueries they are, etc.
Download demo: Java version