Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the operation of mysql similar to merge

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Today, I will talk to you about the operation of mysql similar to merge, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Mysql > truncate `200702`

Query OK, 0 rows affected (0.01 sec)

Mysql > select * from `200702`

Empty set (0.01sec)

Mysql > insert into `200702` (`domain`, `2nd_ domain`, `tld`, `query_ ns1`, `query_ ns2`, `report_ date`) values ('dnspod.com',' dnspod', 'com', 1000, 2000,' 2007-02-04') ON DUPLICATE KEY UPDATE `query_ ns1` = `query_ ns1` + 1000, `query_ ns2` = `query_ ns2` + 2000

Query OK, 1 row affected (0.00 sec)

Mysql > select * from `200702`

+-- +

| | id | domain | 2nd_domain | tld | query_ns1 | query_ns2 | query_ns3 | query_ns4 | report_date |

+-- +

| | 1 | dnspod.com | dnspod | com | 1000 | 2000 | 0 | 0 | 2007-02-04 |

+-- +

1 row in set (0.00 sec)

Mysql > insert into `200702` (`domain`, `2nd_ domain`, `tld`, `query_ ns1`, `query_ ns2`, `report_ date`) values ('dnspod.com',' dnspod', 'com', 1000, 2000,' 2007-02-04') ON DUPLICATE KEY UPDATE `query_ ns1` = `query_ ns1` + 1000, `query_ ns2` = `query_ ns2` + 2000

Query OK, 2 rows affected (0.01sec)

Mysql > select * from `200702`

+-- +

| | id | domain | 2nd_domain | tld | query_ns1 | query_ns2 | query_ns3 | query_ns4 | report_date |

+-- +

| | 1 | dnspod.com | dnspod | com | 2000 | 4000 | 0 | 0 | 2007-02-04 |

+-- +

1 row in set (0.01 sec)

Mysql >

Of course, when building tables, don't forget to make a unique for domain.

UNIQUE KEY `domain` (`domain`, `report_ date`)

After reading the above, do you have any further understanding of mysql's merge-like operation? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report