Mysql query resolved