[Solved] - Unexpected Token: 'AS', expected: 'SET' lazarus / 16-Databases ---------------------------------------------------------------------- kholyphoenix1 · 2019-09-08 10:00 Hello, I'm new to Lazarus. I have the following question. Why when I run this SQL is reporting this error? He is not allowing me to put AS. QuerySQL -> SQL UPDATE acesso_historico AS ah, acesso_cadastro AS ac SET ultimoAcesso = :ultimoAcesso WHERE ac.usuario = :usuario AND ah.id = ac.id    Error: Unexpected Token: 'AS', expected: 'SET' ---------------------------------------------------------------------- fred · 2019-09-08 10:24 I have no sql server at hand but I think UPDATE supports only one table, the AS must be used in a FROM statement. ---------------------------------------------------------------------- ASerge · 2019-09-08 10:43 Quote from: kholyphoenix1 on September 08, 2019, 12:00:57 pmQuerySQL -> SQL UPDATE acesso_historico AS ah, acesso_cadastro AS ac SET ultimoAcesso = :ultimoAcesso WHERE ac.usuario = :usuario AND ah.id = ac.id    Unexpected Token: 'AS', expected: 'SET' Only one table or view can appear in an update statement. ---------------------------------------------------------------------- kholyphoenix1 · 2019-09-08 11:01 How can I solve this? Because I have 2 tables that interact between yes through the column 'matricula'. What do I do? ---------------------------------------------------------------------- fred · 2019-09-08 11:26 You can use FROM and JOIN, see some examples: https://www.techonthenet.com/sql_server/update.php https://www.tutorialgateway.org/how-to-update-from-select-in-sql- server/ https://travishorn.com/update-from-another-table-in-sql-382507f9ff6a ---------------------------------------------------------------------- kholyphoenix1 · 2019-09-08 11:27 UPDATE acesso_historico SET ultimoAcesso = :ultimoAceso WHERE usuario = :usuario (Error) SQLQuery: Cannot open a non-select statement. ---------------------------------------------------------------------- ASerge · 2019-09-08 11:36 Quote from: kholyphoenix1 on September 08, 2019, 01:27:12 pmUPDATE acesso_historico ... SQLQuery: Cannot open a non-select statement. Open only to SELECT, for other - ExecSQL;