sql嵌套话语
sql嵌套语句现有表news含字段id,title,addtime,content等。我想从最新添加的10条新闻中随机读取3条出来,求
sql嵌套语句
现有表news含字段id,title,addtime,content等。我想从最新添加的10条新闻中随机读取3条出来,求解。
[解决办法]
select
top 3 *
from
(select top 10 * from news order by addtime desc)t
order by newid()
[解决办法]select top 3 * from (select top 10 * from news order by id desc) t order by newid()
[解决办法]t相当于一个表别名,t前面那个()里面的内容,是一个子查询,把它查询出的结果,当成一个名字叫:t的表看。like this: select top 3 * from t order by newid()