mysql - 将不同表中的两列相乘
问题描述
我有两张桌子
项目
Id quantity price
01 200 100
02 200 300
交易
Id Quantity
01 1
但是当我乘以输出是
Total
100
300
我的查询是 select items.p*transaction.quantity as total from items,transaction
解决方案
这是你想要的吗?
select (t.quantity * i.price) as total
from transactions t join
items i
on t.id = i.id;
不过,这两个表会在id
.
推荐阅读
- python - 如何在 Dask Series.apply 中指定参数“元”?
- node.js - data.insertOne() 上的 Mongo DB 超时
- javascript - JavaScript Array.includes - 如何使用扩展运算符检查多个值
- java - 在 SurfaceView Android Studio 中使位图可点击
- list - 滑动 ListTile 覆盖 Flutter 中的父级
- python - 如何为 Voronoi 多边形的 PatchCollection 选择颜色并为其创建离散颜色条?
- typescript - 重构我的代码后的新问题:“无效的道具:道具的类型检查失败”
- javascript - 在Javascript中按html元素拆分
- svelte - ibm svelte组件正确使用
- python-3.x - warnings.filterwarnings("ignore") 不会忽略 logging.warning