PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, March 17, 2022

[FIXED] Using MySQL to calculate difference of 2 columns to equal a 3rd column

 March 17, 2022     mysql, phpmyadmin, sql     No comments   

Issue

Ok so I'm using SQL in phpmyadmin trying to calculate the difference from 2 columns and add that value to a 3rd column. I've imported my data by CSV into the database. I'm trying to "autosum" like excel and Access in SQL database.

My columns are "Tax Collected" - "Tax Paid" = "Tax Gain"

Imported CSV


Solution

That we could proper answer, you should best provide e. g. the table create statement, I assume here that you already defined/added a 3rd column of proper data type and default NULL.

This can IMHO be done with standard SQL command like e. g.

   UPDATE 
     YourTableName
   SET 
     TaxGain = TaxCollected - TaxPaid
   WHERE 
     TaxGain IS NULL


Answered By - BitLauncher
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing