0
所以现在我有3个疑问:如何从多个查询中进行乘法和除法?
让我们把这个查询x
SELECT count(*) as totalDrink from
Drink D join History H where H.drinkName = D.name AND type = 'vodka' and userID = 'sai'
查询Ÿ
SELECT count(*) as totalDrink from
Drink D join Favorite F where F.drinkName = D.name AND type = 'vodka' and userID = 'sai'
查询ž
SELECT SUM(totalDrinks) as total FROM (
SELECT COUNT(*) totalDrinks FROM History
WHERE userID = 'sai'
UNION ALL
SELECT COUNT(*) FROM Favorite
WHERE userID = 'sai'
) as totalDrink
基本上我想要做的mySQL和输出:
(X + Y(0.666))/ Z
只是要注意: Querys X,Y和Z将每个输出端只需1元组,所以我觉得应该有一种标量乘法的方法? – user2981811