myPHP Admin Linking Table / Columns
I've been looking at this all day and there doesn't seem to be an online source that does what I need. I want to set the value of Total_Price = Product_TCost + Shipping_TCost. Online sources only give me the option of selecting them and making a new table, but it does not dynamically change with the information. I want to just enter the Product_TCost and Shipping_TCost and have Total_Price automatically insert the value - just how TIMESTAMP works.
I am having some trouble trying to do a Computed Column Specification using phpMyAdmin. I am used to SQL using Microsoft SQL Server Management Studios.
- When I try to insert ([Product_Total]+[Shipping_Total]) in my Total_Price column, I get an error.
- My Product_TCost column in Invoice table should be ([SmallBox_Total]*9.99 + ([LargeBox_Total]*14.99)
- My Shipping_TCost column in Invoice table should be ([SmallBox_Total]*0.99 + ([LargeBox_Total]*1.99)
Same goes with trying to auto populate ID_Order with Shipping_Company in my Invoice table.
I had it all working in SQL management Studios, but phpMyAdmin has a completely different user interface. I didn't use the SQL commands too much, I did everything with the Column Properties from Microsoft SQL Studios.
Basically what I am doing and ultimately failing - using phpMyAdmin - is this:
- When I enter an ID_Order into the Invoice table, it should pull the SmallBox_Total, LargeBox_Total, and auto-calculate the Product_TCost, Shipping_TCost and Total_Price
- When ID_Order is entered, the Shipping_Company should automatically be pulled as well
- The only thing not being pulled is the MCT_Code, which will be entered by the user.
I had this working beautifully in Microsoft SQL Studios, but transferring it over to a foreign system (to me) has completely stopped my progress.
Sounds like you need a trigger. You can create a trigger that will do both of these things; it basically gets attached to the INSERT on ID_Order and runs whatever commands you want including automatically calculating values to insert in other columns.