xxxxxxxxxx
UPDATE t1 SET c=c+1 WHERE a=1 OR b=2 LIMIT 1;
xxxxxxxxxx
INSERT INTO t1 (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=3;
INSERT INTO t1 (a,b,c) VALUES (4,5,6)
ON DUPLICATE KEY UPDATE c=9;
xxxxxxxxxx
# Birinchi tablitsani kerakli columnni Unique qilish kerak shundagina bu narsa ishlaydi
INSERT INTO `order_comments_status` (
`order_id`, `status`, `created_at`,
`updated_at`
) VALUES (
# Agar ma'lumot bo`lmasa shularni insert qil
'5555', '6', now(), now()
) ON DUPLICATE KEY
UPDATE
# Mavjud bo'lsa shularni yangila
status = '6',
updated_at = now()
xxxxxxxxxx
INSERT INTO table_tags (tag) VALUES ('tag_a'),('tab_b'),('tag_c') ON DUPLICATE KEY UPDATE tag=tag;
xxxxxxxxxx
INSERT INTO `student3` (`id`, `name`, `class`, `social`, `science`, `math`) VALUES
(2, 'Max Ruin', 'Three', 86, 57, 86),
(3, 'Arnold', 'Three', 56, 41, 76),
(4, 'Krish Star', 'Four', 62, 52, 72),
(5, 'John Mike', 'Four', 62, 82, 92),
(6, 'Alex John', 'Four', 58, 93, 83),
(7, 'My John Rob', 'Fifth', 79, 64, 74),
(8, 'Asruid', 'Five', 89, 84, 94),
(9, 'Tes Qry', 'Six', 77, 61, 71),
(10, 'Big John', 'Four', 56, 44, 56),
(11,'New Name','Five',75,78,52)
ON DUPLICATE KEY UPDATE social=values(social),science=values(science),math=values(math);
xxxxxxxxxx
INSERT INTO table (column_list)
VALUES (value_list)
ON DUPLICATE KEY UPDATE
c1 = v1,
c2 = v2,
;
xxxxxxxxxx
INSERT INTO `tableName` (`a`,`b`,`c`) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE `a`=VALUES(`a`), `b`=VALUES(`b`), `c`=VALUES(`c`);