我正在使用mysql和sails.js。当我要查询游戏前10名的人,我用:从我的数据库打印页面前10位玩家最简单的方法是什么?
Select name, totalwins/totalgames from user order by totalwins desc limit 10;
这会显示这样的事情在我的终端(缩短到3为例):
+-----------------------+----------------------+
| name | totalwins/totalgames |
+-----------------------+----------------------+
| name 1 | 1.7917 |
| name 2 | 1.5417 |
| name 3 | 0.3333 |
+-----------------------+----------------------+
如果我还想要打印到我的页面上本质上使记分牌刷新更新,我怎么能这样做呢?有没有一种通用的方式来与MySQL做到这一点?
您的表格列是否真的名为“totalwins/totalgames”? – Adam
不,我使用'totaltgames'来划分'totalwins'列,以基本模拟击球平均数。 –
亚当表示您应该添加'totalwins/totalgames AS WinLoseRatio'(或不同的东西) –