This is how the workflow goes:
player logout/disconnect --> triggers OnPCLogoutEvent --> then server saves their data to SQL
You can use set and it will work, but if you want to manually edit data with query_sql, the trick is to use sleep 1000; (detach RID, and pause script) first. Detaching the RID completes the character logout and allows the server to save their data to SQL. Then you can edit with query_sql.
If you used 'query_sql' before they were completely logged out, anything you changed would just get overwritten when the server saves their data to SQL.