查詢表中數據

今天做產品列表,需要查詢其中幾條數據,如下
 
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)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章