Mhanaz Syed Mhanaz Syed - 10 days ago 6
SQL Question

how to updated table with dynamic data in where conditioner in mysql

i am trying to Updated view using this query :

UPDATE tableview SET status = 1 where event_id in (SELECT eventsId
FROM tableview2 where status <>1)


using this Query i am getting 1,2,3,4

SELECT eventsId
FROM tableview2 where status <>1


but when i try to Updated it show more than one column operand please suggest me how to Updated it

Answer

it will work for you

  UPDATE tableview v1
    inner join  tableview2 v2 on v1.event_id =v2.event_id
    SET status = 1 
    where v2.status<>1