update t_book b1
set b1.fyearpublished=2005
where
(
select count(*) from t_book b2
where b1.fcategoryid=b2.fcategoryid
)>3
这个语句用来将所有同类书本数超过三本的图书的出版日期更新为2005
执行语句总有错误提示 如下:
Msg 102, Level 15, State 1, Line 1
'b1' 附近有语法错误。
Msg 102, Level 15, State 1, Line 7
'>' 附近有语法错误。
set b1.fyearpublished=2005
where
(
select count(*) from t_book b2
where b1.fcategoryid=b2.fcategoryid
)>3
这个语句用来将所有同类书本数超过三本的图书的出版日期更新为2005
执行语句总有错误提示 如下:
Msg 102, Level 15, State 1, Line 1
'b1' 附近有语法错误。
Msg 102, Level 15, State 1, Line 7
'>' 附近有语法错误。
set fyearpublished=2005
where fcategoryid in(
select fcategoryid from t_book group by fcategoryid having count(*)>3
)
update某表也可以给该表设置别名?LZ这样的写法真的比较少见。1楼的分组和子查询就可以搞定了。