I have two tables - 'clients' and 'clients_address'
There is on table 'clients' column with name 'phone'. I need to have the same column 'phone' in table 'clients_address'
I create column 'phone' in table 'clients_address' and whit this command I copied the data from 'clients.phone':
UPDATE clients_addresses
SET clients_addresses.phone=(SELECT clients.phone
FROM clients
WHERE clients.id=clients_addresses.client_id);
Everything is copied correctly, but it is not autoupdate. And after new user registration i need to execute this command again. I try with trigger, but SQL return me sintax error. This is what I try:
CREATE TRIGGER up
ON clients.phone
AFTER INSERT
BEGIN
UPDATE clients_addresses
SET clients_addresses.phone=(SELECT clients.phone
FROM clients
WHERE clients.id=clients_addresses.client_id)
END;
I am not very good in sql. Please help.