Complex query editable lazarus / 16-Databases ---------------------------------------------------------------------- xinyiman · 2012-01-04 08:04 How can I edit a query inside a DBGrid which is a join between two tables? And 'possible or not? Error: cannot update a complex query with more then one table ---------------------------------------------------------------------- ludob · 2012-01-04 08:46 Quote from: xinyiman on January 04, 2012, 09:04:27 amHow can I edit a query inside a DBGrid which is a join between two tables? And 'possible or not? Error: cannot update a complex query with more then one table TSqlQuery can not create automatically the update/insert/delete SQL for multi-table selects. You'll have to create these yourself. UpdateSQL, InsertSQL and DeleteSQL use special pre-defined variables :fieldname and :OLD_fieldname (replace 'fieldname' with the real field name). :fieldname is the current value in your DBGrid, :OLD_fieldname the value in the database. Example: Code: [Select]update MyTable  set Name = :name, multiplier = :multiplier  where Name = :OLD_name and multiplier = :OLD_multiplier Note that you can specify only a single query. So updating multiple tables with this technique won't be possible. In that case you can use stored procedures if the database has them and call these from UpdateSQL, etc.