Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2016
    Posts
    2

    Answered: MySQL column calculate multiple

    Hi
    this is my first post here, I have an excel table, I want to create a table in MySQL with same functionality. the excel table has 3 columns. these for car sale price. column names are JAPAN, USA, CANADA. the car price in Japan is different in USA & CANADA, which I calculate for USA (JAPAN*0.8) & for CANADA (JAPAN*0.92). how can I do this in MySQL. I found some solution but those only for query, but what I want is, there will always be 3 columns in the MySQL, so when I put car price in Japan, it will calculate the price for USA & Canada automatically.

    could you please help me.
    thank you

  2. Best Answer
    Posted by DNance

    "Something like:

    create table car_sales_price(japan decimal(9,2), USA decimal(9,2) generated always as (japan*.8), Canada decimal(9,2) generated always as (japan*.92)"


  3. #2
    Join Date
    Oct 2007
    Posts
    161
    Provided Answers: 9
    Something like:

    create table car_sales_price(japan decimal(9,2), USA decimal(9,2) generated always as (japan*.8), Canada decimal(9,2) generated always as (japan*.92)

  4. #3
    Join Date
    Dec 2016
    Posts
    2
    Quote Originally Posted by DNance View Post
    Something like:

    create table car_sales_price(japan decimal(9,2), USA decimal(9,2) generated always as (japan*.8), Canada decimal(9,2) generated always as (japan*.92)
    thank you so much, this works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •