查询如何为MySQL每行乘以2个单元格? [英] How can a query multiply 2 cell for each row MySQL?

查看:98
本文介绍了查询如何为MySQL每行乘以2个单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为每行乘以2个单元格,并将其值放在称为Total的最后一列中.可以通过普通查询来做到吗?

I want to multiply 2 cells for each row and put the value of that in the last column called Total. Can this be done by a normal query?

示例:

Pieces | Price | Total
6      |   4   |  null // should be 24
2      |  10   |  null // should be 10

推荐答案

使用此:

SELECT 
    Pieces, Price, 
    Pieces * Price as 'Total' 
FROM myTable

这篇关于查询如何为MySQL每行乘以2个单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆