format string for query