TugQL vs SQL
See the clause order and execution difference between a TugQL read query and a SQL SELECT statement.
A filtered read
Both examples describe a filtered projection from a table named Invoice. They are illustrative syntax; actual results depend on the data and executor.
TugQL
from Invoice as i
where i.InvoiceId > 1
order by i.InvoiceId asc
select i.InvoiceId, i.CustomerId
SQL
SELECT i.InvoiceId, i.CustomerId
FROM Invoice AS i
WHERE i.InvoiceId > 1
ORDER BY i.InvoiceId ASC;
TugQL places select after the source and modifiers; SQL places SELECT first. Compare the TugQL syntax sheet with the PostgreSQL SELECT reference.
What the executor receives
A SQL database executes SQL in its dialect. TugQL text is parsed into a structured query and resolved for a DALgo-backed executor; it is not passed as raw SQL to PostgreSQL, SQLite or another backend. The structured TugQT form can be serialized to YAML or JSON for review and reuse. The TugQT guide shows a saved tree.
SQL dialect features vary. TugQL also has its own syntax and implementation limits, and each DALgo adapter has different capabilities. Do not assume that a SQL statement can be pasted into TugQL, or that a TugQL construct executes on every adapter.
Which one fits?
Use SQL when you are working directly with a SQL engine and need its dialect and database features. Consider TugQL when a tool needs a read-query model that can be bound to supported SQL or non-SQL DALgo sources, or a reviewable query tree. Verify the exact query and adapter before relying on cross-backend execution.
Sources: PostgreSQL SELECT documentation; TugQL specification; DALgo implementation.