错误代码: 1582 Incorrect parameter count in the call to native function 'str_to_date'

1. 错误描述

1 queries executed, 0 success, 1 errors, 0 warnings

查询:SELECT t.`name`, DATE_FORMAT(str_to_date(‘2015‘), ‘%Y‘) as statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS ...

错误代码: 1582
Incorrect parameter count in the call to native function ‘str_to_date‘

执行耗时   : 0 sec
传送时间   : 0 sec
总耗时      : 0 sec

2. 错误原因

SELECT
  t.`name`,
  DATE_FORMAT(STR_TO_DATE(‘2015‘), ‘%Y‘) AS statisDate,
  ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amount
FROM
  t_stu_info t
WHERE 1 = 1
  AND DATE_FORMAT(t.statisDate, ‘%Y‘) = ‘2015‘
UNION
ALL
SELECT
  t.`name`,
  DATE_FORMAT(STR_TO_DATE(‘2014‘), ‘%Y‘) AS statisDate,
  ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amount
FROM
  t_stu_info t
WHERE 1 = 1
  AND DATE_FORMAT(t.statisDate, ‘%Y‘) = ‘2014‘

MySQL内置函数str_to_date的格式是:str_to_date(字符串,日期格式);

在这个查询SQL中却是str_to_date(字符串),导致报错

3. 解决办法

修改查询SQL语句

SELECT
  t.`name`,
  DATE_FORMAT(STR_TO_DATE(‘2015‘,‘%Y‘), ‘%Y‘) AS statisDate,
  ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amount
FROM
  t_stu_info t
WHERE 1 = 1
  AND DATE_FORMAT(t.statisDate, ‘%Y‘) = ‘2015‘
UNION
ALL
SELECT
  t.`name`,
  DATE_FORMAT(STR_TO_DATE(‘2014‘,‘%Y‘), ‘%Y‘) AS statisDate,
  ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS amount
FROM
  t_stu_info t
WHERE 1 = 1
  AND DATE_FORMAT(t.statisDate, ‘%Y‘) = ‘2014‘

版权声明:本文为博主原创文章,未经博主允许不得转载。

错误代码: 1582 Incorrect parameter count in the call to native function 'str_to_date'

时间: 2024-10-14 10:35:38

错误代码: 1582 Incorrect parameter count in the call to native function 'str_to_date'的相关文章

错误代码 1582 Incorrect parameter count in the call to native f

1. 错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:SELECT t.`name`, DATE_FORMAT(str_to_date('2015'), '%Y') as statisDate, ROUND(IFNULL(SUM(t.`amount`), 0), 3) AS ... 错误代码: 1582 Incorrect parameter count in the call to native function 'str

Incorrect parameter count in the call to native function 'ISNULL'

1.错误描述 Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect parameter count in the call to native function 'ISNULL' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAc

Incorrect column count: expected 1, actual 5,JdbcTemplate queryForList 出错

spring JdbcTemplate  queryForList 出错 Incorrect column count: expected 1, actual 5 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ?Copyright 蕃薯耀 2017年7月10日 http://www.cnblogs

错误代码 1366 Incorrect integer value 'zhangsan' for column 'd

1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:insert into emp values(6,'胡迪',20,'男') 错误代码: 1366 Incorrect integer value: 'zhangsan' for column 'depart_teacher' at row 1 执行耗时 : 0 sec 传送时间 : 0 sec 总耗时 : 0 sec 2.错误原因 DELIMITER $$ CREATE /

Incorrect column count: expected 1, actual 4 问题

解释: 期望的结果是1, 实际的结果是 4 ,  对象有4个属性,表有4 个字段 原因: jdbcTemplate.queryForList(selectSql.toString(), entityClass)  : this.jdbcTemplate.queryForObject(sql, SysUser.class); 一  .而  queryForList  方法参数的解释是这样的: Java代码   Parameters: sql SQL query to execute element

MySQL时间函数-获取当前时间-时间差

MySQL中获取当前时间为now(),不同于sqlserver getdate(). SQLServer转MySQL除变化top 1 -> limit 1之后报错: select 1 from record_visitor where visitor_ip='' and datediff(mi,visitor_time,getdate())<=30 limit 1 [Err] 1582 - Incorrect parameter count in the call to native func

MySQL greatest()和least()函数与MAX()和MIN()函数

下面的内容是个人学习记录,来自https://www.yiibai.com/mysql/greatest-least.html.请大佬勿喷,这里是要强调一点东西. MySQL GREATEST和LEAST函数介绍 它跟MAX()与MIN()函数的区别就是,前面是比较多个字段(列)的最大值最小值,后面是只获取单个字段(列)的最大最小值. GREATEST和LEAST函数都使用N个参数,并分别返回最大和最小值.下面说明GREATEST和LEAST函数的语法: GREATEST(value1, val

mysql 中 isnull 和 ifnull 判断字段是否为null

数据库中经常有字段type为null ,对于统计count(type)和avg(type) 都不起作用 SQL中有ISNULL方法,介绍如下: ISNULL使用指定的替换值替换 NULL. 语法ISNULL ( check_expression , replacement_value ) 参数check_expression将被检查是否为 NULL的表达式.check_expression 可以是任何类型的.replacement_value在 check_expression 为 NULL时将

mysql 判断字段是否为null

SQL中有ISNULL方法,介绍如下: ISNULL使用指定的替换值替换 NULL. 语法ISNULL ( check_expression , replacement_value ) 参数check_expression将被检查是否为 NULL的表达式.check_expression 可以是任何类型的.replacement_value在 check_expression 为 NULL时将返回的表达式.replacement_value 必须与 check_expresssion 具有相同的