update app id
update syntax of SQL query for clarity