Question: I'm trying to calculate all the correct answer a user gets and update it in the score table. But it gives me a fun little error.

```
UPDATE score
SET end_time = CURTIME(), final_score = COUNT(
    SELECT *
    FROM answered
    WHERE (exam_id = 8 and student_login = 'user' and guessed = 1)
)
WHERE exam_id = 8 and student_login = 'user'

```

Error: 

> 
> #1064 - You have an error in your SQL syntax; check the manual that
>  corresponds to your MySQL server version for the right syntax to use
>  near 'SELECT \* FROM answered WHERE (exam\_id = 8 and student\_login =
>  'user' and gue' at line 3
> 
> 
> 

This should be simple enough right? Then what is up with this error? The select works on its own. and the update works without the final\_score update.

Thanks for the help!

Answer: 
```
UPDATE score
SET end_time = CURTIME(), final_score = (
    SELECT COUNT(*)
    FROM answered
    WHERE (exam_id = 8 and student_login = 'user' and guessed = 1)
)
WHERE exam_id = 8 and student_login = 'user'

```

Should do it.

COUNT cannot (as far as I know) operate on sub queries.
try this..

```
UPDATE score
SET end_time = CURTIME(), final_score = (
    SELECT cnt=count(*)
    FROM answered
    WHERE (exam_id = 8 and student_login = 'user' and guessed = 1)
)
WHERE exam_id = 8 and student_login = 'user'

```