Hey all,
I have a table called mailers which I want to update the mailer_states_id with a user required input and update contacts_first_filter_id field with the id of the contact from the contacts_first_filter table whose address, city, and zip code (in the contacts_first_filter table) is equal to the address, city, and zip code of the update query table. The reason is because the update query table has the people who are in the contacts_first_filter table, so I want to update the contacts_first_filter_id of mailer with the id of that contact from contacts_first_filter.
This is query I have:
I get syntax error in update statement and it highlights the first SET. I assume it's an issue with the nested joins.Code:UPDATE mailers AS m INNER JOIN (UpdateQuery INNER JOIN contacts_first_filter ON UpDateQuery.Address = contacts_first_filter.addresses AND UpdateQuery.City = contacts_first_filter.cities AND UpdateQuery.Zip = contacts_first_filter.zip_code ) SET m.mailer_states_id = [user input], m.created_at = Time.now(), m.contacts_first_filter_id = contacts_first_filer.id;
Thanks for response.