MySQL Forums
Forum List  »  MySQL for Visual Studio

Getting a table to update when a certain option is selected
Posted by: James Davies
Date: September 29, 2015 03:07AM


I am relatively new to MySQL so I was hoping that somebody could help me. I am not sure if this is the correct place to put this but I will go ahead anyway.

I am looking for a query that updates another table depending on what opion is selected (Reservation,Appointment, MMC, SYC Appointment, SYC Valuation Form and Not Available). Each of these are worth a different Value (See below)...

Reservation 2
Appointment 2
SYC Appointment 1
SYC Valuation Form 1
Not Available 0

I have used this query:

UPDATE vehicle_collection.ind_summary
JOIN vehicle_collection.form
ON vehicle_collection.ind_summary.TM_ID = vehicle_collection.form.TM_ID
JOIN vehicle_collection.result
ON vehicle_collection.form.Enquiry_Result_ID = vehicle_collection.result.Enquiry_Result_ID
SET ind_summary.Total_Points = ind_summary.Total_Points + vehicle_collection.result.EnquiryValues,
ind_summary.Target_Countdown = ind_summary.Target_Countdown - vehicle_collection.result.EnquiryValues
WHERE vehicle_collection.ind_summary.TM_ID = " 115 " ;

Table 1:
Enquiry_ID|TM_ID| username|Enquiry_Result_ID
1 115 Bob Appointment

Table 2 (Updating)

TM_ID| Total_Points|Target_Countdown|
115 0 100

Once the form is submitted I want it to look like this:-

TM_ID| Total_Points|Target_Countdown|
115 2 98

The issue with this query is for each option, the second table doesn't update untill it has been entered twice??

Options: ReplyQuote

Written By
Getting a table to update when a certain option is selected
September 29, 2015 03:07AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.