Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 查询表达式中的mod抛出语法错误(缺少运算符)_Sql_Ms Access - Fatal编程技术网

Sql 查询表达式中的mod抛出语法错误(缺少运算符)

Sql 查询表达式中的mod抛出语法错误(缺少运算符),sql,ms-access,Sql,Ms Access,以下是我查找闰年的代码: 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; 但它返回的是: Syntax error (missing operator) in query expression 'MOD(year(birth_date),

以下是我查找闰年的代码:

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;
但它返回的是:

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;

我无法找出问题所在

根据错误声明猜测,您正在使用MS ACCESS

mod的语法为:

因此,您的查询变得固定:

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
);


你试过%吗?为了检查mod函数是否出错,还需要指定DBMS

选择名字、姓氏、出生日期 来自学生 其中年份出生日期%4=0 出生年月日%100=0 年出生日期%400=0


答案取决于您没有指定的数据库引擎。哪个DBMS?MySQL、SQL Server等?或。绝对应该是或者@阿南-真的吗?试试看:如果yearbirth\u date mod 400=0,那么yearbirth\u date mod 100将始终为0。只是说:@Anand-和false或true=true,这意味着and将使其成为,因此这种情况每400年评估一次为真。还是说我要疯了@以1992年为例,它可以被4整除,但不能被100整除。。所以正确与正确或错误=>正确
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
);
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
;