BK201 Posted June 10, 2012 Share Posted June 10, 2012 I only have a pretty basic understanding of SQL just enough thats gotten me by whenever I needed to use a database for whatever I was writing. I can't seem to find an answer to my specific question via google. I want the value of say column 3 to equal the difference of column 2 - column 1 for every row in the table. I don't have to update a existing database, I'm working on a text-based rpg and working on creating the database. Quote Link to comment Share on other sites More sharing options...
requinix Posted June 10, 2012 Share Posted June 10, 2012 You don't need that third column. You already know what its values are so there's no point in storing it. It would just mean more data you have to insert and update. SELECT column1, column2, column2 - column1 AS column3, ... Or just do the math in your code. $column3 = $row["column2"] - $row["column1"]; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.