我有這個表: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