sql-parser
sql-parser copied to clipboard
Reconstruct statement
Hi,
thank you for this wonderful library. I just started today an am already enjoying using it.
I have a use case where I have statement like
SELECT a,b,c FROM users WHERE a > 1
Now suppose I want to reconstruct the SQL query string removing WHERE and replacing Select columns with let say * so that the statement becomes:
SELECT * FROM users
I know the library provides a list of statements (where I can choose which one I don't want to have them but then how do I glue the wanted pieces into a complete statement?
TIA, Stefano
Hi Stefano,
glad that the library is of use to you. Just to clarify: Is your expected output another SQL statement? If yes, that is not something that we support at the moment.
It should not be too complex to add operator<<
methods to the different classes and recreate a SQL statement. Once that is done, actually replacing the columns (SelectStatement::selectList) with a single *
is straight forward.
Hi, I don't expect full statement but rather building blocks. For example from Select I can get the table and columns. That's enough to build Select statement. In where I could get conditions, et al.
Are those things available already (I know I can get the table from one issue I found on repo)
I know I can get the table from one issue I found on repo
Could you give me a link? Maybe that will help me understand better what you are looking for.
OK I will put exhaustive explanation when at home!