在ACCESS和SQL Server下Like 日期類型查詢區別

來源:互聯網
上載者:User

最近在用ACCESS資料庫是遇到的問題總結:

一、在ACCESS中LIKE的用法

Access裡like的萬用字元用法是這樣:

“?”表示任何單一字元; “*”表示零個或多個字元; “#”表示任何一個數字

所以應該是:

select * from databasename where fieldname like '*XX*'

但在SQL SERVER 裡是用%表示零個或多個字元

二、如何在ACCESS查詢datetime類型欄位的日期範圍資料

如果欄位是時間/日期型,你在進行類似這樣的執行
select * from [card] where [datetime] <= '2006-09-20' and [datetime]>='2006-09-01'
在ACCESS中會報錯,應該在日期型欄位前面加上“#”即:
select * from [card] where [datetime] <= #2006-09-20# and [datetime]>=#2006-09-01#

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.