蓝派网(www.lan27.com)-精选网络资源,分享和交流! 文章首页站内搜索在线手册广告代码酷站欣赏万年历
您现在的位置: 蓝派网 >> 文章中心 >> 数据库 >> MS-SQL >> 正文

在ACCESS中LIKE的用法

作者:佚名    文章来源:db.rdxx.com    更新时间:2008-1-14 15:41:42

Access里like的通配符用法是这样:
    “?”表示任何单一字符; “*”表示零个或多个字符; “#”表示任何一个数字
    所以应该是:
    select * from databasename where fieldname like '*XX*'


原来在SQL SERVER 里是用%%的,在ACCESS里是用**号的,怪不得都找不到数据!

但如果在VS2005的TableAdapter里又要用%%,用* 不行!!!

 

 所以应该是: 

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

原来在SQL SERVER 里是用%%的,在ACCESS里是用**号的,怪不得都找不到数据!

但如果在VS2005的TableAdapter里又要用%%,用*不行!


ACCESS中LIKE的用法

Like Operator
Compares a string expression to a pattern in an SQL expression.

Syntax
expression Like 'pattern'
The Like operator syntax has these parts:

Part Description 
expression SQL expression used in a WHERE clause. 
pattern String or character string literal against which expression is compared. 


Remarks
You can use the Like operator to find values in a field that match the pattern you specify. For pattern, you can specify the complete value (for example, Like “Smith”), or you can use wildcard characters to find a range of values (for example, Like “Sm*”).

In an expression, you can use the Like operator to compare a field value to a string expression. For example, if you enter Like “C*” in an SQL query, the query returns all field values beginning with the letter C. In a parameter query, you can prompt the user for a pattern to search for.

The following example returns data that begins with the letter P followed by any letter between A and F and three digits:
Like 'P[A-F]###'

The following table shows how you can use Like to test expressions for different patterns.

Kind of match 
Pattern Match 
(returns True) No match 
(returns False) 

Multiple characters a*a aa, aBa, aBBBa aBC 
*ab* abc, AABB, Xab aZb, bac 

Special character a[*]a a*a aaa 
Multiple characters ab* abcdefg, abc cab, aab 

Single character a?a aaa, a3a, aBa aBBBa 
Single digit a#a a0a, a1a, a2a aaa, a10a 

Range of characters [a-z] f, p, j 2, & 
Outside a range [!a-z] 9, &, % b, a 

Not a digit [!0-9] A, a, &, ~ 0, 1, 9 
Combined a[!b-m]# An9, az0, a99 abc, aj0

  • 上一篇文章:
  • 下一篇文章:
  • 百度搜索: 在ACCESS中LIKE的用法

  • 发表评论】【打印此文】【关闭窗口】【点击数:
    ★好玩的休闲小游戏★

    本 栏 推 荐

    本 栏 热 门

    站 内 推 荐

    图 文 推 荐