JavaEar 专注于收集分享传播有价值的技术资料

ERROR 1582 (42000): Incorrect parameter count in the call to native function 'STR_TO_DATE'

I am looking for some help regarding the error I am receiving in MySQL. I am fairly new to MySQL. I have the following table:

+--------------+--------------+------+-----+-------------------+-----------------------------+
| Field        | Type         | Null | Key | Default           | Extra                       |
+--------------+--------------+------+-----+-------------------+-----------------------------+
| date         | date         | NO   |     | NULL              |                             |
| time         | timestamp    | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| messure      | decimal(9,2) | NO   | PRI | NULL              |                             |
| inject_units | decimal(9,2) | YES  |     | NULL              |                             |
+--------------+--------------+------+-----+-------------------+----------------

I am using the below query to insert data into the table

INSERT INTO sugar_levels (date, time, messure, inject_units) VALUES ('2017-08-22',STR_TO_DATE('2017-08-22 05:50:00', 'Y%-m%-d% H%:m%:s', '11.7', '12'));

But I am getting the following error:

ERROR 1582 (42000): Incorrect parameter count in the call to native function 'STR_TO_DATE'

Please help as this it might be a simple syntax error.

1个回答

    最佳答案
  1. 3 errors:

    First % sign must be before the letters Second missing %sign before the second placeholder Third The bracket is at wrong place:

    INSERT INTO sugar_levels (date, time, messure, inject_units) 
     VALUES ('2017-08-22',STR_TO_DATE('2017-08-22 05:50:00', '%Y-%m-%d %H:%m:%s'), '11.7', '12');