0

i'm really new to mysql triggers so...i have 3 tables: a,b and c. table a is related with table b with a one to many relaion and table c is the table that get the triggered infromation from the 2 other tables.

 table a
 ------------------
  id     |    name
   1     |    Juan 
   2     |    Pete
   3     |    David

 table b
 ----------------------
  id  |  name   | table_a_id
   1  |  Dog    |     1
   2  |  Cat    |     2

Table C gets the information from Table A with a "after insert on A for each row insert into C "also gets information From table B with a "after insert on B for each row update C".

 table c
----------------------
id | name a | name b | table_a_id |table_b_id
 1 |  juan  |   Dog  |      1     |      1
 2 |  Pete  |   Cat  |      2     |      2

The problem occurs when Pete wants to have Cat and Dog at the same time because it will just update Pete's information. What i want is a way in which i can have a new row with all the information.

      table c
     -------------------------------------------
    id | name a | name b | table_a_id |table_b_id
     1 |  juan  |   Dog  |      1     |      1
     2 |  Pete  |   Cat  |      2     |      2
---->3 |  Pete  |   Dog  |      2     |      1

This 3rd row from table C wont be created it will just update row 2 from table C. Please tell e if i was clear enough.

  • Why you need in 3rd table? You can freely and easily obtain this data from first 2 tables using one simple query when needed... – Akina Mar 21 at 16:06
  • cause m using metabase to make some graphs and you cannot do inner joins on it – cirlord Mar 21 at 16:48
  • cannot do inner joins on it Use cartesian + condition, what a problem? Or your metabase allow single-table selections only? – Akina Mar 21 at 16:51
  • yup, single tables selections only. Thats why im in this trouble now – cirlord Mar 21 at 16:52
  • Does INSERT .. ODKU and/or REPLACE are available? – Akina Mar 21 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.