What is the best way to insert into and update a single row table in MySQL?

前端 未结 2 1679
余生分开走
余生分开走 2020-12-11 10:07

I have a MySQL table that will only have one row. What should my statement be for the first time I insert to this row, and for subsequent updates? I tried an insert where th

2条回答
  •  攒了一身酷
    2020-12-11 10:44

    INSERT INTO table(col1,col2,col3) VALUES(val1,val2,val3) ON DUPLICATE KEY UPDATE col1 = val1, col2 = val2, col3 = val3;
    

提交回复
热议问题