I have a table with two columns: ColumnA
and ColumnB
.
How can I add a third column to my table that is ColumnA
divided by ColumnB
?
I know this seems simple, but I have been unable to find the syntax.
You mean something like this:
SELECT ColumnA,
ColumnB,
(ColumnA / ColumnB) as ColumnC
FROM myTable
or to actually add a new column and fill it with the result of ColumnA
divided by ColumnB
like this:
ALTER TABLE `myTable` ADD `ColumnC` INT NOT NULL;
UPDATE `myTable` SET ColumnC = (ColumnA / ColumnB);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.