$foo = mysql_query('SELECT * FROM bar WHERE candy=9'); if (mysql_num_rows($foo) > 0) { // ya existe el registro... } else { // NO existe!! }