Title: Allow querying internal Data Tables using SQL syntax
The idea:
Add an option inside the “Data Table” node or a new dedicated node to run standard SQL queries (SELECT, WHERE, JOIN) directly against the built-in n8n Data Tables.
My use case:
Currently, to filter, sort, or perform complex logic (like joining data from two native tables), we have to pull all data using “Get Rows” and create complex JavaScript workarounds inside a Code Node. Allowing SQL queries natively would make internal data manipulation much faster and more powerful for advanced users.
Hi @Fabiano_Faria
That would be a bit of a security risk. As then you would of course be able to query the other tables in the n8n database.
Of course nothing stops you to just add the postgres node + credentials for the n8n database and query it that way.
I do agree it would be nice to have more query functions and to be able to query with sql syntax would be great, but then it does need a bit of work on the security side.
The JOIN use case especially - pulling two tables and merging them cleanly in a Code node gets messy fast. A workaround that helps right now: pull both tables via “Get Rows”, then use a Code node with alasql (add it to NODE_FUNCTION_ALLOW_EXTERNAL) to run actual SQL against the arrays in memory. Not native, but it handles SELECT/WHERE/JOIN without writing custom merge logic.
Still +1 on native SQL support - it would make Data Tables actually useful for complex data ops without always reaching for a Code node.
If you are pulling everything via Get Rows and doing joins and filtering in a Code Node, that would add a lot of overhead for something the SQL can handle natively in one line. In the meantime a workaround is to use a Merge node make sure it is set to Combine by matching fields for the more JOIN style logic instead of raw JS, and then chain a Filter/Sort node for your WHERE/ORDER BY. This cuts down on scripting over the cleaner SQL. You should also post this as a feature request on n8n’s official feature-request board so it can get tracked and upvoted properly.