Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two tables in mysql

Table: objects

1: ID  (Auto Increment)         INT        eg: 1
2: Object (like "Flower)        TEXT       eg: Flower
3: Rank (like 90, calculated)   FLOAT      eg: 90

Table: Rankings

1: ID  (Auto Incement)          INT        eg: 1,2,3,4,5,
2: Object (like "Flower")       TEXT       eg; Flower,Flower,Flower,Flower,Flower
3: Person (like "Peter")        TEXT       eg: Peter,Hans,Markus,Emil,Egon
4: Ranking ( +/- Points)        FLOAT      eg: 100, -10 , -10 , -10 , 20

So, The Rank from Table1, is a sumary of all Rankings in Table2 where Object = Object.Table1. In this case it would be 90 for the Flower.

How can I build a trigger (on insert) for this? Every time someone posts a ranking the Rank.Table1 gets updated via a trigger.

Sorry for this question, but I'm very new to this.

share|improve this question
Use a view instead. – Phil Dec 16 '13 at 20:05
I dont think a view is possible in my case, cuz i do a Mysql_fetch_row in php, and then it would call always the same view, didnt it, so there had to be on view per Object? – user3101966 Dec 16 '13 at 20:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.