查询表中数据

今天做产品列表,需要查询其中几条数据,如下
 
select top 6 * from tablename where id not in(select top 6 id from tablename order by id desc) order by id desc
注意:子查询里面不能select * ,查询 * 的时候会报错,所以最好的办法是select id
 
 
随机查询其中几条数据
 
select top 4 * from tablename order by rnd(id)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章