Reputation: 35
I have 2 MySQL tables like these
| email | bounce | status |
|email |
what i want is a query to update the (bounce and status column) main table with respect to the data from bounce table
this is the query i tried, update main inner join bounce on (main.email = bounce.email) set main.bounce='yes' and main.status='Inactive';
Upvotes: 1
Views: 96
Reputation: 35
One of the column name in main table is same as the 2nd table name "bounce" , that's why update statement didn't work
update main inner join bounce on (main.email = bounce.email) set main.bounce='yes' and main.status='Inactive';
from the above query, main.bounce
doesn't represents the column in main table instead it points to the second table "bounce"
You can update the table by either
update main inner join bounce on (main.email = bounce.email) set main.status='Inactive';
update main set bounce='yes' where status='Inactive';
Upvotes: 1
Reputation: 452
You should try
UPDATE main m
INNER JOIN bounce b
ON m.email=b.email
SET m.bounce="yes" AND m.status="Inactive";
Upvotes: 1