fixed queries so they work for mysql