fix database query in profile api

1aa8087cca2671ed1905318f87a32a9304e59a89