{"id":602,"date":"2006-05-26T10:15:21","date_gmt":"2006-05-25T22:15:21","guid":{"rendered":""},"modified":"2006-05-26T10:15:21","modified_gmt":"2006-05-25T22:15:21","slug":"","status":"publish","type":"post","link":"https:\/\/www.mudone.com\/?p=602","title":{"rendered":"\u7528\u4e00\u6761SQL\u5f97\u5230Access\u6570\u636e\u5e93\u4e2d\u7684\u968f\u673a\u8bb0\u5f55\u96c6."},"content":{"rendered":"<p>\u9488\u5bf9\u201c\u7528\u4e00\u6761SQL\u5f97\u5230\u6570\u636e\u5e93\u4e2d\u7684\u968f\u673a\u8bb0\u5f55\u96c6\u201d\u95ee\u9898\u5728\u7f51\u4e0a\u5df2\u7ecf\u6709\u5f88\u591a\u7b54\u6848\u4e86\uff1a<br \/>\nSQL Server 2000:<br \/>\nSELECT TOP n * FROM tanblename ORDER BY NEWID()<br \/>\nAccess<br \/>\nSELECT TOP n * FROM tanblename ORDER BY rnd([\u4e00\u4e2a\u81ea\u52a8\u7f16\u53f7\u5b57\u6bb5]) <\/p>\n<p>\u597d\u4e86\uff01\u5c31\u8bf4\u8bf4\u8fd9\u4e2aAccess\u7684\uff01 <\/p>\n<p>\u6253\u5f00Access2003\u5efa\u7acb\u4e00\u4e2a\u5e26\u6709\u81ea\u52a8\u7f16\u53f7\u5b57\u6bb5\u7684\u8868 T1 : id_(auto),content_<br \/>\n\u968f\u4fbf\u63d2\u5165\u4e9b\u8bb8\u8bb0\u5f55 <\/p>\n<p>\u7136\u540e\uff0c\u70b9\u9009\u201c\u67e5\u8be2\u201d\u65b0\u5efa\u4e00\u4e2a\u67e5\u8be2\uff0c\u201c\u8bbe\u8ba1\u89c6\u56fe\u201d\uff0c\u9009\u62e9T1\uff0c\u7136\u540e\u9009\u62e9SQL\u89c6\u56fe\uff08\u8fd9\u6837\u53ef\u4ee5\u5199\u81ea\u5df1\u7684SQL\u4e86\uff0c\u6bd4\u8f83\u4e60\u60ef\uff09\uff0c\u597d\u4e86\uff0c\u5199\u5427\uff1a <\/p>\n<p>SELECT TOP 3 [content_] FROM [T1] ORDER BY rnd([id_]) <\/p>\n<p>\u7136\u540e\u8fd0\u884c\u4e00\u4e0b\u7ed3\u679c\uff0c\u55ef\u8bb0\u4f4f\u4e86\u662f\u4ec0\u4e48\u7ed3\u679c\u54e6\u3002<br \/>\n<!--more--><br \/>\n\u8fd4\u56deSQL\u89c6\u56fe\uff0c\u518d\u8fd0\u884c\u770b\u7ed3\u679c\uff0c\u8ddf\u4e0a\u6b21\u7684\u4e0d\u4e00\u6837\uff01\u90a3\u5c31\u5bf9\u4e86\uff01\uff08\u5f53\u7136\u4f60\u7684T1\u91cc\u522b\u53ea\u6709\u5c11\u4e8e3\u6761\u7684\u8bb0\u5f55\u5440\uff09 <\/p>\n<p>\u597d\u4e86\uff0c\u6211\u4eec\u662f\u641eWEB\u5f00\u53d1\u7684\uff01<br \/>\n\u5199\u4e2aASP\u770b\u770b <\/p>\n<\/p>\n<p>&lt;%<\/p>\n<p> Dim Con,RS<br \/>\n  Set Con = Server.CreateObject(&quot;ADODB.CONNECTION&quot;)<br \/>\n  Con.ConnectionString = &quot;Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=&quot; &amp; Server.MapPath(&quot;*.mdb&quot;)<br \/>\n  Con.CommandTimeout = 20<br \/>\n  Con.CursorLocation = 3<br \/>\n  Con.Open <\/p>\n<p>  Set RS = Con.Execute(&quot;SELECT TOP 3 [content_] FROM [T1] ORDER BY rnd([id_])&quot;)<br \/>\n  Do While Not RS.EOF<br \/>\n   Response.Write RS.Fields(&quot;content_&quot;).Value &amp; &quot;&lt;br \/&gt;&quot;<br \/>\n   RS.MoveNext<br \/>\n  Loop<br \/>\n  RS.Close<br \/>\n  Set RS = Nothing <\/p>\n<p>  Con.Close<br \/>\n  Set Con = Nothing\n    <\/p>\n<p>%&gt;<\/p>\n<\/p>\n<p>\u5728localhost\u4e0a\u8fd0\u884c\u4e00\u4e0b\u8fd9\u4e2aASP\uff0c\u770b\u5230\u7ed3\u679c\u4e86\u5427\uff0c\u8bb0\u4f4f\uff01\u518dF5\u4e00\u4e0b\uff01\u54a6\uff1f~~~~~~~~~~~\u8fd8\u90a3\u4e2a\u7ed3\u679c\uff01\u8fd9\u53ef\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\uff01<br \/>\n\u5f53\u7136\u4e86\uff0crnd\u5728\u8fd0\u884c\u524d\u5e94\u8be5\u6267\u884cRandomize\u8bed\u53e5\u7684\uff01<br \/>\n\u53ef\u662f\u600e\u4e48\u6267\u884c\uff1f<br \/>\nAccess\u91cc\u652f\u6301Randomize\u4e48\uff1f\u6211\u7684Access\u4e5f\u4e0d\u662f\u5f88\u719f\uff0c\u770b\u4e86\u4e00\u4e0b\u5e2e\u52a9\uff0c\u53ea\u627e\u5230\u4e86VBS\u91cc\u7684\u90a3\u4e2aRandomize\u2026\u2026<br \/>\n\u89e3\u51b3\u95ee\u9898\u662f\u6bcf\u4e2a\u7a0b\u5e8f\u5458\u6700\u6765\u7cbe\u795e\u7684\uff01<br \/>\n\u8d76\u7d27Google\u4e00\u4e0b\uff01<br \/>\n\u7ffb\u4e86\u534a\u5929\u4e5f\u6ca1\u6709\u597d\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u6709\u7684\u5e72\u8106\u7528asp\u6765\u5faa\u73af\u7684\u627eposition\uff0c\u5478\uff0c\u8d39\u4e86\u534a\u5929\u52b2\u5e72\u4ec0\u4e48\u5462\uff0c\u6211\u5c31\u60f3SQL\u89e3\u51b3\u600e\u4e48\u529e\uff1f <\/p>\n<p>Access\u91cc\u7684Randomize\u4e0d\u77e5\u9053\u600e\u4e48\u7528\uff0casp\u7684\u57fa\u672c\u529f\u8fd8\u4f1a\u5427\uff1f\u5f00\u52a8\u8111\u7b4b\uff0c\u6709\u4e86\uff01 <\/p>\n<p>&lt;%<\/p>\n<p> Dim Con,minPID,RS<br \/>\n  Set Con= Server.CreateObject(&quot;ADODB.CONNECTION&quot;)<br \/>\n  Con.ConnectionString = &quot;Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=&quot; &amp; Server.MapPath(&quot;*.mdb&quot;)<br \/>\n  Con.CommandTimeout = 20<br \/>\n  Con.CursorLocation = 3<br \/>\n  Con.Open <\/p>\n<p>  Randomize<br \/>\n  Set RS = Con.Execute(&quot;SELECT TOP 3 [content_] FROM [T1] ORDER BY rnd(-(id_+&quot; &amp; rnd() &amp; &quot;))&quot;)<br \/>\n  Do While Not RS.EOF<br \/>\n   Response.Write RS.Fields(&quot;content_&quot;).Value &amp; &quot;&lt;br \/&gt;&quot;<br \/>\n   RS.MoveNext<br \/>\n  Loop<br \/>\n  RS.Close<br \/>\n  Set RS = Nothing <\/p>\n<p>  Con.Close<br \/>\n  Set Con = Nothing <\/p>\n<p>%&gt; <\/p>\n<p>\u55ef\uff0c\u8fd9\u56de\u518d\u8bd5\u4e00\u8bd5\uff01 <\/p>\n<p>OK\u4e86\uff01\u6bcf\u6b21F5\u540e\u90fd\u80fd\u662f\u201c\u968f\u673a\u201d\u7684\u611f\u89c9\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9488\u5bf9\u201c\u7528\u4e00\u6761SQL\u5f97\u5230\u6570\u636e\u5e93\u4e2d\u7684\u968f\u673a\u8bb0\u5f55\u96c6\u201d\u95ee\u9898\u5728\u7f51\u4e0a\u5df2\u7ecf\u6709\u5f88\u591a\u7b54\u6848\u4e86\uff1a SQL Server 2000: S [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[],"tags":[],"class_list":["post-602","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/posts\/602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mudone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=602"}],"version-history":[{"count":0,"href":"https:\/\/www.mudone.com\/index.php?rest_route=\/wp\/v2\/posts\/602\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mudone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mudone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mudone.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}