我有这个表:sql - 我如何创建一个表我有一个upsert?
create table comment_check (
record_id int (10) unique not null AUTO_INCREMENT ,
member_id int (10) not null unique ,
has_question_comment bool ,
has_business_comment bool
);
这UPSERT:
INSERT INTO comment_check
(member_id , has_question_comment)
VALUES
(4815162342, 1)
ON DUPLICATE KEY UPDATE
has_question_comment = 1
但我感到困惑的是我有两个按键,RECORD_ID,并且是真正的关键的member_id。当我创建表格时,我应该将member_id列标记为关键字吗?我该如何区分查询中的两个键(member_id和record_id)?
谢谢!
用于['upsert'](https://www.google.com/search?q=define+upsert)的+1。从未听说过它。 – Kermit
@njk谢谢,加上“upsert”听起来很酷:) – Genadinik
其实这是一个很常见的词,至少在数据仓库的世界。 – fancyPants