NeoZephyr / Post-It-Note

0 stars 0 forks source link

SQL 语句 #6

Open NeoZephyr opened 2 years ago

NeoZephyr commented 2 years ago
insert into T(tid, count) values (1, 1000), (2, 3000)
on duplicate key update count = values(count), last_updated = "2020-01-01";
on duplicate key update customer_id=IF(values(customer_id) IS NULL, customer_id, VALUES(customer_id))
if(score is not null, score, 0)
NeoZephyr commented 2 years ago
INSERT INTO block_detail (uid, block_count)
VALUES (?, 1) ON DUPLICATE KEY UPDATE block_count = block_count + 1
NeoZephyr commented 2 years ago
update namespace set version = case project_id
    when 0 then 10
    when 1 then 100
    else 1000
    end;

select
case
    when gender = 0 then '男'
    when gender = 1 then '女'
    else '未知'
end as gender
from customer;

select if(gender = 0, '男', if(gender = 1, '女', '未知')) as gender
from customer;