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.

This is the column properties I used in Microsoft SQL Management Studio

This is my database and where I can't get the linking done correctly

Basically what I am doing and ultimately failing - using phpMyAdmin - is this:

  1. 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
  2. When ID_Order is entered, the Shipping_Company should automatically be pulled as well
  3. 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.

Answers


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.

http://dev.mysql.com/doc/refman/5.7/en/trigger-syntax.html


Need Your Help

Is there a way to delete objects from database without locking?

ios objective-c core-data

I have an object with one-to-many relationship and cascade delete rule. Deleting of this object initiates deleting of many related objects (30 000 and more). When I save context after deleting, it ...

The function strcpy doesn't work

c++ c

I had a homework saying that i should