What is this error? "Database query failed: Data truncated for column 'column_name' at row 1

前端 未结 3 943
别跟我提以往
别跟我提以往 2021-02-05 04:12

I\'m building a PHP/MySQL application and I\'m running into a problem with my create and update query. I have 5 columns that are set to type FLOAT that are also set as NULL colu

3条回答
  •  半阙折子戏
    2021-02-05 04:26

    If you aren't going to INSERT the data it should not be in the SQL statement.

    As an example, say you have a table "Data" with id, float1, float2, float3, and float4, Float5, of which you will only be adding the ID. The INSERT should look like this:

    INSERT INTO `Data` ( `id` )
    VALUES ( 'Some-ID-Value' )
    

    If the floats are defined to accept NULL they will be defaulted to NULL. The same goes for UPDATE statements, you should only list fields you will be altering.

提交回复
热议问题