I have a 3 tables:
1. Users — here “userd id” is primary key
2. UserPermision –here “userd id” is a foreign key and there is “pageid” coloumn
3. Page — here page id is a primary key
Now i need to write a query when i inser a new user say user id = “1” then this user id 1 should be inserted into Userpermision table and for this user it shouls have all the pages from page table .
I’m assuming you are using InnoDB.
In that case you have foreign key constraints and transactions.
If not you’ll have to use triggers.
This is assuming you’ve already made pages for that user.
link
http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html