ACCESS模糊查詢

2021-06-28 00:28:28 字數 641 閱讀 8666

原文:

access模糊查詢出現的問題,開發中需要注意!

在sql server中模糊查詢通常是這樣的select * from articletable where authorname like '%jacky%'

但是在access中用這條語句執行的時候竟然發現查不出結果,怎麼可能呢?

後來查了下資料,發現問題如下:

要進行模糊查詢,則必須使用萬用字元,access庫的萬用字元和sql server的萬用字元不一樣。

access庫的萬用字元為:

*  與任何個數的字元匹配。

?  與任何單個字母的字元匹配

在sql server中的萬用字元為:

% 與任何個數的字元匹配

-  與單個字元匹配

正確寫法應是:

在c#裡寫應寫成 select * from table where name like '%jacky%' 

select * from table where name like '_jacky_' 

access內測試語句應寫成 : select * from table where name like '*jacky*' 

select * from table where name like '?jacky?'

ACCESS模糊查詢

access模糊查詢出現的問題,開發中需要注意 在sql server中模糊查詢通常是這樣的select from articletable where authorname like jacky 但是在access中用這條語句執行的時候竟然發現查不出結果,怎麼可能呢?後來查了下資料,發現問題如下 ...

ACCESS模糊查詢

access模糊查詢出現的問題,開發中需要注意 在sql server中模糊查詢通常是這樣的select from articletable where authorname like 關鍵字 但是access的萬用字元和sql server的萬用字元不一樣。access資料庫內測試時的萬用字元為 ...

Access 引數 模糊 查詢

string sql select from tbproduct where classid in ids and productname like productname order by id desc oledbparameter sps new oledbparameter 1 sps 0 ...