I am new to jsqlparser and trying to parse the sql statement to get table name and its query type (In Java).
For eg1.
INSERT INTO Customers (CustomerName, Country)
SELECT SupplierName, Country FROM Suppliers
WHERE Country='Germany'
From this query, I want to get the table name Suppliers
and its query type SELECT
.
Similarly, table name Suppliers
and its query typeINSERT
.
For eg2.
UPDATE CUSTOMERS SET SALARY = SALARY * 0.25
WHERE AGE IN (SELECT AGE FROM CUSTOMERS_BKP WHERE AGE >= 27 )
From this query, I want to get the table name CUSTOMERS_BKP
and its query type SELECT
.
Similarly, table name CUSTOMERS
and its query typeUPDATE
.
For eg3.
UPDATE CUSTOMERS SET SALARY = SALARY * 0.25
WHERE AGE IN (SELECT AGE FROM CUSTOMERS WHERE AGE >= 27 )
(I knew that this query can be simplified, but for example I have pasted here.)
From this query, I want to get the table name CUSTOMERS
and its query type SELECT
.
Similarly, table name CUSTOMERS
and its query typeUPDATE
.
Note: here table names are same but different query type.
Same way, I want to get the table name and its query type for any complex sql query.
Could you please help me on this?
Please comment, if you want me to provide any details.