Sorry if this has been posted before; I am not sure what to search for.
I have a table of users, `users`.
In the table `users` there is a row which stores clicks, `users`.`clicks `.
Each user has it's own referrer, `users`.`referr er_id` which refrences the referring user's id.
In the referring user's row, I would like a field to store referral clicks, `users`.`referr al_clicks`.
I would like `users`.`referr al_clicks` to be updated each time that a child user's `users`.`clicks ` field is changed.
Is this easily possible in MySQL?
Is this more efficient than something like:
[code=mysql]SELECT SUM(`users`.`cl icks`) FROM `users` WHERE `users`.`referr er_id` = 1;[/code]
as opposed to:
[code=mysql]SELECT `users`.`referr al_clicks`) FROM `users` WHERE `users`.`id` = 1;[/code]
Thanks,
Ben Manns
I have a table of users, `users`.
In the table `users` there is a row which stores clicks, `users`.`clicks `.
Each user has it's own referrer, `users`.`referr er_id` which refrences the referring user's id.
In the referring user's row, I would like a field to store referral clicks, `users`.`referr al_clicks`.
I would like `users`.`referr al_clicks` to be updated each time that a child user's `users`.`clicks ` field is changed.
Is this easily possible in MySQL?
Is this more efficient than something like:
[code=mysql]SELECT SUM(`users`.`cl icks`) FROM `users` WHERE `users`.`referr er_id` = 1;[/code]
as opposed to:
[code=mysql]SELECT `users`.`referr al_clicks`) FROM `users` WHERE `users`.`id` = 1;[/code]
Thanks,
Ben Manns
Comment