Queries allow only Select
statements. Other types of SQL (such as Insert
) need to be run in Tools->SQL..
or in another program such as Workbench.
Edit 8/11/16:
In reply to your last comment, a basic practice in database design is not to save data which can be calculated from somewhere else. I have many such tables which are constantly being updated and are used to generate balances. When needed, these totals are generated from these tables to get the most current information. That being said, here is a macro for your SQL:
Sub RunUpdateSQL
Dim oStatement As Object
Dim sSQL As String
if IsNull(Thisdatabasedocument.CurrentController.ActiveConnection) then
Thisdatabasedocument.CurrentController.connect
endif
oStatement = Thisdatabasedocument.CurrentController.ActiveConnection.createStatement()
sSQL = "UPDATE ""Total"" SET ""Total"".""IssueTotal"" =" &_
" (SELECT SUM( ""Issue"".""Quantity"") FROM ""Issue""" &_
" WHERE ""Issue"".""ProductName""=""Total"".""ProductName""" &_
" GROUP BY ""Issue"".""ProductName"")"
oStatement.executeUpdate( sSQL )
End Sub
This statement is based strictly upon the information in you question.