I'm sorry for such a newbie question, but I have two tables:
vtiger_assets
+-----------+---------+------+-----+---------+----------------+
| assetid | account | Stat | Key | Default | assetname |
+-----------+---------+------+-----+---------+----------------+
| 224 | int(11) | NO | PRI | NULL | |
| 225 | int(11) | NO | | NULL | |
| 226 | date | NO | | NULL | |
| 227 | date | NO | | NULL | |
| 228 | int(11) | NO | | NULL | |
| 229 | int(11) | NO | MUL | NULL | |
| 230 | int(11) | NO | MUL | NULL | |
+-----------+---------+------+-----+---------+----------------+
And vtiger_assetscf
+--------------+---------+
| assetid | cf_658 |
+--------------+---------+
| 224 | Value 1 |
| 225 | Value 2 |
| 226 | Value 3 |
| 227 | Value 2 |
| 228 | Value 3 |
| 229 | Value 1 |
| 230 | Value 3 |
+--------------+---------+
After one day of trying and errors using Trigger, INSERT and UPDATE I give up and decided to ask the experts...
A new row is added in both tables at the same time (with a new assetid automatically added)
I need to automatically import and update (populate) the values from cf_658 column at vtiger_assetcf table to the assetname column at vtiger_assets table.
I have tried:
create trigger 'ativos' after insert on vtiger_assetscf
for each row
begin
insert into vtiger_assets (assetid, assetname) values (new.assetid, new.cf_658);
end#
I have tried a combination of INSERT and UPDATE. No luck...
Can someone help me?