0

hi2,

Could anyone please show me how to update a dataValue each time a data in another database changes its value ?


Here is a screenshot of my 2 databases I would like that;

Each time a value in database1-table1 is changing,
It sends a trigger to change the age value in database2-useragetable

enter image description here



I attempt to create a trigger from this link. Using Trigger to update table in another database
And Here is the code and the screenshot of it.

    AFTER UPDATE ON table1.value  FOR EACH ROW
      BEGIN
    UPDATE TABLE database2.useragetable
    SET  age = NEW.value

    WHERE no = NEW.no
    END;

enter image description here

Hikari
  • 458
  • 1
  • 11
  • 27
  • Possible duplicate of [Using Trigger to update table in another database](https://stackoverflow.com/questions/8910617/using-trigger-to-update-table-in-another-database) – Nishita Apr 29 '19 at 09:41
  • @Nishita Thank you for giving me new insight. however, where should I put the trigger. ? should I create another PHP script.. ? If I'm not asking to much, could you please put a screenshot of where the code should be put.. ? ^_^ – Hikari Apr 29 '19 at 10:05

1 Answers1

1

Please refer to the following wiki to create a trigger:

https://github.com/phpmyadmin/phpmyadmin/wiki/Trigger

  1. In phpMyAdmin, select the database (database1-table1) that you want to work with.

  2. Go to the SQL tab at the top of the page.

  3. In the "Run SQL query/queries on database" form, change the Delimiter to $$. (Located in a small box at the bottom of the form)
  4. Enter your SQL trigger into the main dialog box on the form.
RobC
  • 22,977
  • 20
  • 73
  • 80
Nishita
  • 870
  • 1
  • 9
  • 33
  • Hi Nishita., I am still not sure if the link you gave me work in my case. I tried to implement the answer from @fahim Parkar, but it said that "unrecognized statement type (near after) " I am not sure what i did wrong. – Hikari Apr 29 '19 at 11:11
  • Please post the entire code of the trigger you are trying to run. – Nishita Apr 29 '19 at 11:13
  • I have just put it in my question.. thank you very much for your help Nishita. ^^ – Hikari Apr 29 '19 at 11:21
  • do you have any way to solve the problem.. ? I would appreciate it. – Hikari Apr 30 '19 at 07:32