[英]mod throwing Syntax error (missing operator) in query expression
here is my code to find leap years:这是我查找闰年的代码:
Select first_name, last_name,birth_date
FROM students
WHERE MOD(year(birth_date),4) =0
AND MOD(year(birth_date),100) =0
AND MOD(year(birth_date),400) =0;
but it returns this:但它返回这个:
Syntax error (missing operator) in query expression
'MOD(year(birth_date),4) =0
AND MOD(year(birth_date),100) =0
AND MOD(year(birth_date),400) =0;
and I can't figure out the problem我无法弄清楚问题所在
Guessing from the error statement, you are using MS ACCESS
.从错误声明中猜测,您正在使用
MS ACCESS
。
Syntax for mod
is: mod
语法是:
n1 mod n2
So, your query becomes (fixed):因此,您的查询变为(固定):
SELECT first_name, last_name,birth_date
FROM students
WHERE year(birth_date) mod 4 = 0
AND (
NOT year(birth_date) mod 100 = 0
OR year(birth_date) mod 400 = 0
);
or或者
SELECT first_name, last_name,birth_date
FROM students
WHERE (
NOT year(birth_date) mod 100 = 0
AND year(birth_date) mod 4 = 0
) OR year(birth_date) mod 400 = 0
;
Have you tried "%"?你有没有尝试过 ”%”? Just to examine if it's error from mod function, also, specify your DBMS would be helpful too,
只是为了检查它是否来自 mod 函数的错误,另外,指定您的 DBMS 也会有帮助,
Select first_name, last_name,birth_date FROM students WHERE year(birth_date)%4 =0 AND year(birth_date)%100 =0 AND year(birth_date)%400 =0;
从学生中选择名字、姓氏、出生日期 WHERE year(birth_date)%4 =0 AND year(birth_date)%100 =0 AND year(birth_date)%400 =0;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.