我想插入表中的行,如果還不存在,請更新它。 如何在codeignitor中更改此查詢?使用代碼的條件插入
INSERT INTO fa_seat_details (mall_id, cineplex_name, audi_number, number_of_rows, number_of_columns) VALUES(15, "PVR", 1, 18, 16) ON DUPLICATE KEY UPDATE cineplex_name = "some name", number_of_rows=10, number_of_columns=20;
這是表結構,
+-------------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | mall_id | int(11) | NO | MUL | NULL | | | cineplex_name | varchar(64) | NO | | NULL | | | audi_number | int(11) | NO | | NULL | | | number_of_rows | int(11) | NO | | NULL | | | number_of_columns | int(11) | NO | | NULL | | +-------------------+-------------+------+-----+---------+----------------+
可能是重複的http://stackoverflow.com/questions/3361490/how-would-i-use-on-duplicate-key-update-in-my-codeigniter-model和很多這樣的本 – siddhesh
任何領域的潮頭檢查?? –
mall_id和audi_number的組合在此表中是唯一的 –