Index: res/res_config_sqlite.c =================================================================== --- res/res_config_sqlite.c (revision 333496) +++ res/res_config_sqlite.c (working copy) @@ -1215,10 +1215,10 @@ /* \cond DOXYGEN_CAN_PARSE_THIS */ #undef QUERY -#define QUERY "SELECT * FROM '%q' WHERE commented = 0 AND %q%s '%q'" +#define QUERY "SELECT * FROM '%q' WHERE%s %q%s '%q'" /* \endcond */ - if (!(query = sqlite_mprintf(QUERY, table, params[0], op, tmp_str))) { + if (!(query = sqlite_mprintf(QUERY, table, (config_table && !strcmp(config_table, table)) ? " commented = 0 AND" : "", params[0], op, tmp_str))) { ast_log(LOG_WARNING, "Unable to allocate SQL query\n"); ast_config_destroy(cfg); ast_free(params);