2

これを機能させようとしていますが、エラーが発生しますt_write was not locked.

makecolとcolsnを最高値から更新していますsn + 1

LOCK TABLES 1_makes AS t_read READ, 1_makes as t_write WRITE;

UPDATE t_write 
SET 
    make = 'Pioneer',
    sn = (SELECT 
            *
        from
            (SELECT 
                MAX(sn)
            FROM
                t_read
            WHERE
                id <> 0) as new_sn) + 1
WHERE
    id = 2;

UNLOCK TABLES;
4

1 に答える 1

3

これはどう:

LOCK TABLES 1_makes WRITE, 1_makes AS t_read READ;

UPDATE 1_makes
SET 
    make = 'Pioneer',
    sn = (SELECT 
            *
        from
            (SELECT 
                MAX(sn)
            FROM
                1_makes AS t_read
            WHERE
                id <> 0) as new_sn) + 1
WHERE
    id = 2;

UNLOCK TABLES;
于 2012-08-16T15:07:55.533 に答える