Friday 15 May 2015

sql - MySQL syntax for Join Update -


I have two tables that look like this

train

 < Code> + ---------- + ------------- + ------ + ----- + --------- + - ------ + | Field | Type | Faucet Key | Default | Extra | + ---------- + ------------- + ------ + ----- + --------- + - ------ + | TrainID | Varchar (11) | No | PRI | Faucet | | Capacity Int (11) | No | | 50 | | + ---------- + ------------- + ------ + ----- + --------- + - ------ +  

Reservation

  + --------------- + ---- --------- + ------ + ----- + --------- + ---------------- + | Field | Type | Faucet Key | Default | Extra | + --------------- + ------------- + ------ + ----- + ------ --- + ---------------- + | Reserve | Int (11) | No | PRI | Faucet Auto_interpretation | | First name Varchar (30) | No | | Faucet | | Last name | Varchar (30) | No | | Faucet | | Deedit | Date | No | | Faucet | | Luck | Int (2) | No | | Faucet | | Route | Varchar (11) | No | | Faucet | | Train | Varchar (11) | No | | Faucet | + --------------- + ------------- + ------ + ----- + ------ --- + ---------------- +  

Currently, I am trying to create a query that increases the capacity of the train If the reservation is canceled I know that I have to be one of the participants, but I am not sure how to do this in the update statement. For example, I know how to get the strength of a train, in which a fixed reserved Given, such as:

  Select the reservation on the train. Region = Reserved. Train where Reservation ID = 15 ";  

But I would like to create a query that does this -

  Increase train. Capacity by reservation. If possible, I would like to know how to increase one arbitrary seats. As one side, after the increase in the Java transaction I I am planning to remove the reservation. Will the transaction be removed?  

Thanks for the help!

MySQL supports A, which Looks like this: Resume reservation reserved on train T (R. Train = T. TRIIDID) STT T. Capacity = T. Capacity + R. No where the R reservation ID =?

You can update the train table and remove it from the reservation table in the same transaction. Update times and If you want to delete the other, should work as long.


No comments:

Post a Comment