I have a table notes which is described as :
+---------+--------------+------+-----+-------------------+----------------+
| Field   | Type         | Null | Key | Default           | Extra          |
+---------+--------------+------+-----+-------------------+----------------+
| id      | int(11)      | NO   | PRI | NULL              | auto_increment |
| date    | datetime     | YES  |     | CURRENT_TIMESTAMP |                |
| content | varchar(400) | YES  |     |                   |                |
| page    | int(11)      | YES  |     | -1                |                |
| user_id | int(11)      | YES  | MUL | NULL              |                |
| hasmore | bit(1)       | YES  |     | b'0'              |                |
+---------+--------------+------+-----+-------------------+----------------+
Where page represent page number.
I am unable to create a trigger that can automatically set the page number for my notes when a page is inserted.
And the reason was this statement is not working.  
update notes set page = (select count(*) from notes);
It seems that I cannot query notes to update value of notes itself.
Is there any other method to accomplish my task easily.  
The error I am getting is :
ERROR 1093 (HY000): You can't specify target table 'notes' for update in FROM clause
Edit :
Suppose if I have 2 entries in my table
>select id, user_id, page, content from notes where user_id = 2;
1  |  2  |  0  | "hi"
2  |  2  |  1  | "welcome"
And I insert new data
>insert into notes (user_id, content) values (2, "hello");
Then my table should be like :
>select id, user_id, page from notes where user_id = 2;
1  |  2  |  0  |  "hi"
2  |  2  |  1  |  "welcome"
3  |  2  |  2  |  "hello"
