我必须使用where
通过两个表从表中仅删除列而不是整行。
这是一个例子:
delete from Rating using Movie, Rating
where Movie.mID=Rating.mID
and Rating.stars<4
and (Movie.year<1970 or Movie.year>2000);
此查询有效,但在表'Rating'
中,它会删除整行。我只想删除'stars'
列中的数据。
答案 0 :(得分:1)
您需要更新表格才能执行此操作。您实际上需要更新列stars
可能会更改为NULL
Update stars set NULL // and go on with your query
答案 1 :(得分:0)
您需要update
声明但不需要delete
:
更改:
delete from Rating using Movie, Rating
where Movie.mID = Rating.mID
and Rating.stars<4
and ( Movie.year < 1970 or Movie.year > 2000 );
要强>:
Update Rating r, Movie m
set r.stars = 0
where m.mID = r.mID
and Rating.stars < 4
and ( m.year < 1970 or m.year > 2000 );