开发者

How to insert partial data into a Mysql table?

INSERT INTO sitelist(开发者_Python百科id,rank,websiteaddress,tag1,tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10)
VALUES 
 ('','','','search','searchengine','discover','find','tag5','tag6','tag7','tag8','tag9','tag10') WHERE `id`=1

The thing is that the first row is like this

1 1 google.com nothing nothing etc

I want to insert search searchengine discover find tag5 tag6 etc instead of nothing.


Perform an UPDATE query instead.


you need an UPDATE query, instead of insert. And the case of Update, it's easier to just write the update, than some automation, if there are not so many fields.

If you want default values to be inserted instead of nulls, simply assign default values to those fields, and next time you insert, if you don't specify a value, it will be the default. The changes will "come into effect" on the next time you insert a row with null values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜