fix event query - some DB's have problems with it