Empty values being added to all mysql rows instead of just the target row

后端 未结 2 1987
不知归路
不知归路 2021-01-28 13:47

Empty columns are being added to my MySQL rows upon submitting data into my server. I am entering it into one row but all rows get at least an empty column. How can I prevent th

2条回答
  •  再見小時候
    2021-01-28 14:50

    whenever you do an insert query, sql will insert a whole row. if you only specify one column then all the other columns will be filled with null (or whatever the default value is).

    if you want to fill the other columns in the row you can do that..

    insert into table (col1, col2) values ('val1', 'val2')
    

    If you wan tto update a column in an existing row..

    Update table set column = 'value' where col='somevalue'
    

    bottom line is, you can;t create a row and expect only a single column to be populated. that makes no sense.. where you expecting something like this to happen?

提交回复
热议问题