Search code examples
phpmysqlmysql-error-1241

operand should contain 1 column UPDATE


what sql statements should i use to do something like this?

UPDATE 
`table1`
SET
`media` = 'url'
WHERE
`media` = '3' AND `forum_post_id` = ('109918','109949','109882','109819','109822')

right now i am getting the operand should contain 1 column error


Solution

  • Use "IN":

    UPDATE `table1`
    SET `media` = 'url'
    WHERE`media` = '3' AND `forum_post_id` IN ('109918','109949','109882','109819','109822')
    

    Documentation for "IN"