generate query inserting apostophe  in filters, and ; at end of query