日度归档:2017年6月16日

MySQL UPDATE JOIN

JOIN似乎不太满足这里的需求子查询更好

UPDATE novel 
SET 
    chat_num = (SELECT 
            COUNT(*)
        FROM
            chats
        WHERE
            novel_id = ? AND status = 1)
WHERE
    id = ?

UPDATE JOIN 似乎无法使用limit

UPDATE pay_record
        JOIN
    article_info ON article_info.id = pay_record.object_id 
SET 
    novel_id = special_id
WHERE
    ISNULL(novel_id) AND pay_record.id = 17;