I have the following 2 tables(places & Offer (comapny) in mysql database named COUPON1.81
CREATE TABLE IF NOT EXISTS places (
id int(60) NOT NULL AUTO_INCREMENT,
namevarchar(255) NOT NULL,
Description text NOT NULL,
'Company_id' int(60) NOT NULL,
Active int(60) NOT NULL,
CREATE TABLE IF NOT EXISTS offer_company (
id int(60) NOT NULL AUTO_INCREMENT,
company_name varchar(150) NOT NULL,
Address text NOT NULL,
'places_id' int(60) NOT NULL,
I need to Update the rows from table company_id to table places when insert a new row on table company
Example, if i insert a new row to Offer_company values as ('1', CSB(pvt)limited, srilanka,123) then the the trigger should to UPDATE the rows from table company_id to table places
Places_id select form places table
places table
+----------+-------------+------+-----+---------+-------+-------+-------+
| id | name | Description | Company_id |
+----------+-------------+------+-----+---------+-------+-------+-------+
| 123 | eiffel tower | CSB(pvt)limited | 0 |
| 124 | sigiriya | sigiriya Rock | 0 |
+----------+-------------+------+-----+---------+-------+-------+-------+
Offer _comapny table
+----------+-------------+------+-----+---------+-------+
| id | company_name | Address | places_id|
+----------+-------------+------+-----+---------+-------+
| 1 | CSB(pvt)limited | 89/A,Srilanka | 123 |
+----------+-------------+------+-----+---------+-------+
After select places _id in company table
In Places table, Company_id should be update
places table
+----------+-------------+------+-----+---------+-------+-------+-------+
| id | name | Description | Company_id |
+----------+-------------+------+-----+---------+-------+-------+-------+
| 123 | eiffel tower | is an iron lattice tower | 1 |
| 124 | sigiriya | sigiriya Rock | 0 |
+----------+-------------+------+-----+---------+-------+-------+-------+
i addedthis trigger
DROP TRIGGER IF EXISTS `add`;
DELIMITER //
CREATE TRIGGER `add` AFTER INSERT ON `offer_company`
FOR EACH ROW INSERT INTO places (Company_id)
SELECT new.id
FROM offer_company
WHERE offer_company.places_id = new.places_id
//
DELIMITER ;
but this not working how solve this