2

我的表如下

int_id      Born         Died
 1          2001          0    
 2          2002          0    
 3          1991          0
 4          1992          0
 5          1987         1995
 6          1986         1993
 7          1985         1998

由此,我需要查询只显示死者,确定他们死时的年龄并将该值乘以 3。

我一直在尝试使用 phpMyAdmin 来做到这一点,但到目前为止还没有弄清楚。给予的任何帮助将不胜感激。

4

1 回答 1

8

你试过吗,呃......减法和乘法?

SELECT 
    int_id,
    Died - Born AS age_died,
    3 * (Died - Born) AS age_died_tripled
FROM my_table
WHERE Died > 0;
于 2012-05-01T04:34:59.690 回答