1

I found several questions and answers about Mysql Bulk Update. And found good solutions from these questions - question1, question2.

So my table looks like this.

subscribers

firstname | lastname | subscriberid | inactivereason | statusflag

Here,

firstname => VARCHAR - not null

lastname => VARCHAR - not null

subscriberid => BIGINT - primary key,not null, unique

inactivereason = > VARCHAR - NULL(default)

statusflag => ENUM('YES','NO') - not null

And I have used the following query.

INSERT INTO subscriber (subscriberid,inactivereason,statusflag) VALUES (1002,"nothing","YES"),(1003,"NO Reason","YES"),(1004,"No valid Data","YES"),(1001,"Poor quality","YES")
ON DUPLICATE KEY UPDATE inactivereason=VALUES(inactivereason),statusflag=VALUES(statusflag);

But I got the following error

Error Code: 1364. Field 'firstname' doesn't have a default value

But I cannot make any default value for firstname. Is it mandatory?

So how can I solve this problem? I cannot take the risk of performance because I have more than 100k subscribers.

Please suggest me the best way.

Community
  • 1
  • 1
Renjith V R
  • 2,981
  • 2
  • 22
  • 32

0 Answers0