今天做產品列表,需要查詢其中幾條數據,如下
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)