如何使用触发器和TIMESTAMPDIFF插入年龄

时间:2018-11-29 12:02:53

标签: mysql

捐赠人表:

  1. 个人信息包括名字,出生日期和性别。
  2. 捐赠者必须年满17岁

enter image description here

我用这段代码来计算年龄

def getnumbers():
    x = input("Enter the X number: ")
    y = input("Enter the Y number: ")
    return x, y

def checknumbers():
    if   x > y:
        print(f'x is larger then y: x is {x} and y is {y}')
    elif y > x:
        print(f"y is larger then x: x is {x} and y is {y}")
    elif y == x:
        print(f"x is equal to y: x is {x} and y is {y}")     
    else:
        print("Dont know mate")


n = 0
while(n < 3):
    getnumbers()
    checknumbers()
    n += 1

我使用了此触发器:

select TIMESTAMPDIFF(YEAR, Dbirth, NOW()) AS age FROM Donors;

我的问题是如何同时使用触发器和TIMESTAMPDIFF

0 个答案:

没有答案