2016-11-28 35 views
0

我使用此查詢我試圖更新視圖動態數據:如何更新表在空調在MySQL

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

使用此查詢我得到1,2,3,4

SELECT eventsId 
     FROM tableview2 where status <>1 

但是當我嘗試更新它顯示多列操作請建議我去更新它如何

+0

你可以做內部聯接上,而不是使subquery.That將幫助you.Show您的數據我會創建查詢您 –

+0

加入樣品表中的數據,前和更新後的版本(以及格式化文本。)展我們視圖的定義。 – jarlh

+0

http://paste.ofcode.org/SWTDRhtVv25YzrzChh8WxX檢查它@AnkitAgrawal –

回答

1

它會爲你

工作
UPDATE tableview v1 
    inner join tableview2 v2 on v1.event_id =v2.event_id 
    SET status = 1 
    where v2.status<>1 
0
UPDATE tableview SET status = 1 
FROM tableview2 v2 
WHERE tableview.event_id = v2.event_id AND v2.status<>1