From what I see, your tables are set wrongly for rating tutorials. What you'd want is a new table like this:
CREATETABLE`ratings` ( tut_id INT UNSIGNEDNOTNULL, rating TINYINT UNSIGNEDNOTNULL );
Then you'd insert the rating:
You can get a rating by a subquery, like so:
SELECT *, ( SELECT AVG(`rating`) FROM `ratings` WHERE `ratings`.`tut_id` = `tutorials`.`id` ) AS `rating` FROM `tutorialz`;
Understand that I haven't tested this so I might have made a mistake, but this should work for you.
__________________ Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
The Following User Says Thank You to RobertK For This Useful Post:
webtuto> An INSERT statement cannot use a WHERE clause. You either perform an INSERT and it inserts data (imagine that) or you perform an UPDATE where you can define columns to update WHERE some condition is met.