服務(wù)熱線
153 8323 9821
sql server :
在取數(shù)據(jù)庫(kù)前幾條記錄時(shí)會(huì)碰到取到記錄與語(yǔ)句不符的情況:如select top 5本來(lái)取5條記錄但是確顯示了5條以上的記錄,這是由于在排序時(shí)遇到字段值相同的記錄。解決辦法例:select top 5*from(select top 5*from(select*from nnes here nrole 2order by ntime desc)order by nsho desc)這是一個(gè)雙字段排序語(yǔ)句nsho是我自己定義的一個(gè)排序字段,經(jīng)常出現(xiàn)重復(fù)現(xiàn)象,造成top語(yǔ)句不起作用把select top 5*from(select*from nnes here nrole 2order by ntime desc)order by nsho desc在它嵌套在select top 5*from中就解決了top語(yǔ)句不起作用的現(xiàn)象。
access top語(yǔ)句:SELECT TOP 8 id, qname, img, yw
FROM (SELECT TOP 8 id, qname, img, yw
FROM co
WHERE (sh = 1) AND (zd = 1)) derivedtbl
access語(yǔ)句只需在后面加上 derivedtbl。