Updated SQL Query for AESDatabase