I am looking to make a single SQL statement to select an object from the database and then update that object based on values entered through a form.
I am not used to writing advanced SQL queries and am used to ORM syntaxes, but I would like to get this right.
Currently my query looks like this
SET @person = (
dbo.people as u
inner join dbo.people as pe on pe.people_id = u.people_id
inner join dbo.parties as pa on pa.people_id = pe.people_id
inner join dbo.contact_details as cd on cd.parties_id = pa.parties_id
inner join enum.contact_details_types cdt on cdt.contact_details_types_id = cd.contact_details_types_id
u.people_id = 57121526-03e3-4dc2-bfb8-6c6fc84a9de8 #UUID of the user eg)
You may need this, try it.
update dbo.people u inner join dbo.people as pe on pe.people_id = u.people_id inner join dbo.parties as pa on pa.people_id = pe.people_id inner join dbo.contact_details as cd on cd.parties_id = pa.parties_id inner join `enum`.contact_details_types cdt on cdt.contact_details_types_id = cd.contact_details_types_id on u.people_id = 57121526-03e3-4dc2-bfb8-6c6fc84a9de8' set u.sexes_id = ?, u.marital_states_id = ?, u.employment_states_id = ?, u.linkedins_id = ?, u.facebooks_id = ?, u.first_names = ?, u.surnames = ?, u.name_to_call_user = ?, u.id_number = ?, u.passport_number = ?, u.birth_date = ?, u.tax_number = ?, u.vat_number = ?, u.message_to_show_on_user_invoice = ?, u.workplace_name = ?;