Search query and right sql