有这样一组规则的表达式字符串
完整表达式:[sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#)]
sum还可能是count、max、min、last、first;
=、<>、>可能是sql标准的其他符号,比如:is、>=、<=、like、in、not in等;
where只能有1个,where后面的字符也是标准的运算表达式,符合$A $O $B规则,$O表示操作操作符,$A表示左值,$B表示右值;
表达式内不能有$符号。sum可能没有,tab1.col1可能没有tab1,只有col1,where及后面的可能没有,where前面的一定要有,完整表达式也可能简写成:
[col1]
[col1 where ...]
[sum(col1)]
[sum(col1) where ...]
[sum(tab1.col1)]
[tab1.col1]
[tab1.col1 where ...]大家帮忙写一个通用的适应简写表达式和完整表达式的统一正则校验,可以可以将每个简写的枚举情况分开各写1个,非常感谢!!!
1.通用的适应简写表达式和完整表达式的统一正则校验,另外开贴送200分。
2.以下分开的正则校验本贴送分。
[col1]
[col1 where ...]
[sum(col1)]
[sum(col1) where ...]
[sum(tab1.col1)]
[sum(tab1.col1) where ...]
[tab1.col1]
[tab1.col1 where ...]

解决方案 »

  1.   

    嗯,是挺麻烦,我记得以前有个类似的需求,思归大侠还在csdn的时候给我写出来过,后来让我搞丢了~~~~~~~
      

  2.   

    不是太清楚楼主是用来提取还是单条进行验证,MS验证的成份大些,虽然我并不认为正则适合用来做这种事情,主要是因为这种需求写出的正则,除了作者自己外,几乎不可读,但还是写了一下string[] test = new string[] { "[sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#)]", "[col1]", "[col1 where (col2 = '01' or col3 > 0)]", "[sum(col1)]", "[sum(col1) where col4 <>'02']", "[sum(tab1.col1)]", "[tab1.col1]", "[tab1.col1 where col5 = #cola#]", "[sum(col1) where '姓 名'='c d']", "[sum(col1) where 姓 名=c d]", "[]", "[abs(col1)]" };
    Regex reg = new Regex(@"^\[(?<o>(sum|count|max|min|last|first)\()?[^()\s]+(?(o)\))\s*(where\s*(\([^()]+\)|('[^']*'|\S+)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\([^()]+\)|'[^']*'|\S+))(\s*(and|or)\s*(\([^()]+\)|('[^']*'|\S+)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\([^()]+\)|'[^']*'|\S+)))*)?\s*\]$", RegexOptions.IgnoreCase);
    foreach (string s in test)
    {
        if (reg.IsMatch(s.Trim()))
            richTextBox1.Text += s + " : 符合!\n";
        else
            richTextBox1.Text += s + " : 不符合!\n";
    }
    //输出
    [sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#)] : 符合!
    [col1] : 符合!
    [col1 where (col2 = '01' or col3 > 0)] : 符合!
    [sum(col1)] : 符合!
    [sum(col1) where col4 <>'02'] : 符合!
    [sum(tab1.col1)] : 符合!
    [tab1.col1] : 符合!
    [tab1.col1 where col5 = #cola#] : 符合!
    [sum(col1) where '姓 名'='c d'] : 符合!
    [sum(col1) where 姓 名=c d] : 不符合!
    [] : 不符合!
    [abs(col1)] : 不符合!上面没有处理()嵌套的情况,如果()嵌套是可能的,可以这样写
    string[] test = new string[] { "[sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#)]", "[col1]", "[col1 where (col2 = '01' or col3 > 0)]", "[sum(col1)]", "[sum(col1) where col4 <>'02']", "[sum(tab1.col1)]", "[tab1.col1]", "[tab1.col1 where col5 = #cola#]", "[sum(col1) where '姓 名'='c d']", "[sum(col1) where 姓 名=c d]", "[]", "[abs(col1)]", "[sum(tab1.col1) where ((col2 = '01' or col3 > 0) or col4 <>'02') and col5 = #cola#)]" };
    Regex reg = new Regex(@"^\[(?<o>(sum|count|max|min|last|first)\()?[^()\s]+(?(o)\))\s*(where\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(o)(?!))\)|('[^']*'|\S+)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(o)(?!))\)|'[^']*'|\S+))(\s*(and|or)\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(o)(?!))\)|('[^']*'|\S+)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(o)(?!))\)|'[^']*'|\S+)))*)?\s*\]$", RegexOptions.IgnoreCase);
    foreach (string s in test)
    {
        if (reg.IsMatch(s.Trim()))
            richTextBox1.Text += s + " : 符合!\n";
        else
            richTextBox1.Text += s + " : 不符合!\n";
    }目前写的正则,虽然能够符合楼主所给的例子,但由于我对SQL语法并不够了解,所以还是不够严谨的,有不符合的楼主给出实例,我再写下吧
    目前只能晚上上网,回复的实时性就没法保证了,所以如果没有高手出手,楼主要等我的回复的话,那就尽可能详细的描述需求,给出各种情况的实例
      

  3.   

    楼上很强,你的正则我测试一下,另外给个实际应用的字符串实例吧:
    if (([人员考勤表.ZB where WorkerNumber = #WorkerNumber#]+[sum(人员考勤表.YB)]+[人员考勤表.YB50 where WorkerNumber = #WorkerNumber#])>0 and #PosName#!='运行支持') : #BaseSalary#/21.75*1.5*1.71 else : 0校验是已经将[]内的分解后做的事情了。
      

  4.   

    测试玩了,效果非常好,有几个需要补充完善一下的地方:
    关于:$A $O $B规则的处理这里还有个限制:如果是列名或##夹着的,比如:col1 = #col2#,则col和col2都不能包含特殊字符串(只能是英文或汉字或阿拉伯数字组成,而且不能够数字开头)
    如果是列名等于常值的形式,比如:col1 = 'abc casd .f',col1 > 3.42,则允许包含特殊字符串。例如:'姓 名'='c d' 不允许,因为列名带单引号
    姓 名=c d 不允许,因为列名中间有空格
    姓名=cd 允许,因为是两个合法列明
    姓名=1cd 不允许,因为列名是数字开头了
    姓名 = 'c d.e' 允许,因为是字符串常值
    #姓名# = #cd# 允许,因为是两个合理列名称
    姓名 = #cd# 允许,因为是两个合理列名称
    #姓 名# = #1cd# 不允许,因为列名里面包括空格和数字开头root_,再麻烦一次了!!!
      

  5.   

    上面说的有点错误。重新纠正一下
    测试玩了,效果非常好,有几个需要补充完善一下的地方:
    关于:$A $O $B规则的处理这里还有个限制:如果是列名或##,$$夹着的,比如:col1 = #col2#,则col和col2都不能包含特殊字符(_下划线除外只能是英文或汉字或阿拉伯数字组成,而且不能够数字开头或下划线开头,就是说一旦被##或$$夹着的就要符合数据库列名的规则。)如果是列名等于常值的形式,比如:col1 = 'abc casd .f',col1 > 3.42,则允许包含特殊字符串。例如:'姓 名'='c d' 不允许,因为列名带单引号
    姓 名=c d 不允许,因为列名中间有空格
    姓名=cd 允许,因为是两个合法列名
    姓名=1cd 不允许,因为列名是数字开头了
    姓名 = 'c d.e' 允许,因为是字符串常值
    #姓名# = $cd$ 允许,因为是两个合理列名称
    姓名 = #cd# 允许,因为是两个合理列名称
    #姓 名# = #1cd# 不允许,因为列名里面包括空格和数字开头
    #_姓名# = #cd# 不允许,因为列名里面下划线开头
      

  6.   

    我对SQL语法真的是不够了解,所以就只能是楼主给什么样的实例,我就写什么样的正则了,呵呵,加了这些规则后,比昨天的又长了一些,效率也自然低了一些,这里是没有考虑()嵌套的情况,所以那个有嵌套的结果为不允许,考虑嵌套的正则就更长了string[] test = new string[] { "[sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#]", "[col1]", "[col1 where (col2 = '01' or col3 > 0)]", "[sum(col1)]", "[sum(col1) where col4 <>'02']", "[sum(tab1.col1)]", "[tab1.col1]", "[tab1.col1 where col5 = #cola#]", "[sum(col1) where '姓 名'='c d']", "[sum(col1) where 姓 名=c d]", "[]", "[abs(col1)]", "[sum(tab1.col1) where ((col2 = '01' or col3 > 0) or col4 <>'02') and col5 = #cola#]", "[col1 where '姓 名'='c d']", "[col1 where 姓 名=c d]", "[col1 where 姓名=cd]", "[col1 where 姓名=1cd]", "[col1 where 姓名 = 'c d.e']", "[col1 where #姓名# = $cd$]", "[col1 where 姓名 = #cd#]", "[col1 where #姓 名# = #1cd#]", "[col1 where #_姓名# = #cd#]" };
    Regex reg = new Regex(@"^\[(?<o>(sum|count|max|min|last|first)\()?[^()\s]+(?(o)\))\s*(where\s*(\([^()]+\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\([^()]+\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)|'[^']*'))(\s*(and|or)\s*(\([^()]+\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\([^()]+\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)|'[^']*')))*)?\s*\]$", RegexOptions.IgnoreCase);
    foreach (string s in test)
    {
        if (reg.IsMatch(s.Trim()))
            richTextBox1.Text += s + " : 允许!\n";
        else
            richTextBox1.Text += s + " : 不允许!\n";
    }
    //输出
    [sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#] : 允许!
    [col1] : 允许!
    [col1 where (col2 = '01' or col3 > 0)] : 允许!
    [sum(col1)] : 允许!
    [sum(col1) where col4 <>'02'] : 允许!
    [sum(tab1.col1)] : 允许!
    [tab1.col1] : 允许!
    [tab1.col1 where col5 = #cola#] : 允许!
    [sum(col1) where '姓 名'='c d'] : 不允许!
    [sum(col1) where 姓 名=c d] : 不允许!
    [] : 不允许!
    [abs(col1)] : 不允许!
    [sum(tab1.col1) where ((col2 = '01' or col3 > 0) or col4 <>'02') and col5 = #cola#] : 不允许!
    [col1 where '姓 名'='c d'] : 不允许!
    [col1 where 姓 名=c d] : 不允许!
    [col1 where 姓名=cd] : 允许!
    [col1 where 姓名=1cd] : 不允许!
    [col1 where 姓名 = 'c d.e'] : 允许!
    [col1 where #姓名# = $cd$] : 允许!
    [col1 where 姓名 = #cd#] : 允许!
    [col1 where #姓 名# = #1cd#] : 不允许!
    [col1 where #_姓名# = #cd#] : 不允许!
    加了()嵌套规则的
    string[] test = new string[] { "[sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#]", "[col1]", "[col1 where (col2 = '01' or col3 > 0)]", "[sum(col1)]", "[sum(col1) where col4 <>'02']", "[sum(tab1.col1)]", "[tab1.col1]", "[tab1.col1 where col5 = #cola#]", "[sum(col1) where '姓 名'='c d']", "[sum(col1) where 姓 名=c d]", "[]", "[abs(col1)]", "[sum(tab1.col1) where ((col2 = '01' or col3 > 0) or col4 <>'02') and col5 = #cola#]", "[col1 where '姓 名'='c d']", "[col1 where 姓 名=c d]", "[col1 where 姓名=cd]", "[col1 where 姓名=1cd]", "[col1 where 姓名 = 'c d.e']", "[col1 where #姓名# = $cd$]", "[col1 where 姓名 = #cd#]", "[col1 where #姓 名# = #1cd#]", "[col1 where #_姓名# = #cd#]" };
    Regex reg = new Regex(@"^\[(?<o>(sum|count|max|min|last|first)\()?[^()\s]+(?(o)\))\s*(where\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(op)(?!))\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(op)(?!))\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)|'[^']*'))(\s*(and|or)\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(op)(?!))\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(op)(?!))\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)|'[^']*')))*)?\s*\]$", RegexOptions.IgnoreCase);
    foreach (string s in test)
    {
        if (reg.IsMatch(s.Trim()))
            richTextBox1.Text += s + " : 允许!\n";
        else
            richTextBox1.Text += s + " : 不允许!\n";
    }
    //输出
    [sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#] : 允许!
    [col1] : 允许!
    [col1 where (col2 = '01' or col3 > 0)] : 允许!
    [sum(col1)] : 允许!
    [sum(col1) where col4 <>'02'] : 允许!
    [sum(tab1.col1)] : 允许!
    [tab1.col1] : 允许!
    [tab1.col1 where col5 = #cola#] : 允许!
    [sum(col1) where '姓 名'='c d'] : 不允许!
    [sum(col1) where 姓 名=c d] : 不允许!
    [] : 不允许!
    [abs(col1)] : 不允许!
    [sum(tab1.col1) where ((col2 = '01' or col3 > 0) or col4 <>'02') and col5 = #cola#] : 允许!
    [col1 where '姓 名'='c d'] : 不允许!
    [col1 where 姓 名=c d] : 不允许!
    [col1 where 姓名=cd] : 允许!
    [col1 where 姓名=1cd] : 不允许!
    [col1 where 姓名 = 'c d.e'] : 允许!
    [col1 where #姓名# = $cd$] : 允许!
    [col1 where 姓名 = #cd#] : 允许!
    [col1 where #姓 名# = #1cd#] : 不允许!
    [col1 where #_姓名# = #cd#] : 不允许!655个字符,也创下了我写的最长正则的记录了有不符合的尽可能给出所有情况的实例哈
      

  7.   

    太强了,真是太感谢了!!!最后一个小小要求。[col1 where #姓名# = [cd]] 不允许方括号的嵌套。
      

  8.   

    补充一下前面两点的,不允许嵌套方括号和大括号
    [col1 where #姓名# = [cd]] 不允许
    [col1 where #姓名# = {cd}] 不允许
      

  9.   

    不太明白楼主新的需求是什么意思,后加的这两种情况,在11楼的两个正则里已经是不允许的了不带()嵌套规则的
    string[] test = new string[] { "[sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#]", "[col1]", "[col1 where (col2 = '01' or col3 > 0)]", "[sum(col1)]", "[sum(col1) where col4 <>'02']", "[sum(tab1.col1)]", "[tab1.col1]", "[tab1.col1 where col5 = #cola#]", "[sum(col1) where '姓 名'='c d']", "[sum(col1) where 姓 名=c d]", "[]", "[abs(col1)]", "[sum(tab1.col1) where ((col2 = '01' or col3 > 0) or col4 <>'02') and col5 = #cola#]", "[col1 where '姓 名'='c d']", "[col1 where 姓 名=c d]", "[col1 where 姓名=cd]", "[col1 where 姓名=1cd]", "[col1 where 姓名 = 'c d.e']", "[col1 where #姓名# = $cd$]", "[col1 where 姓名 = #cd#]", "[col1 where #姓 名# = #1cd#]", "[col1 where #_姓名# = #cd#]", "[col1 where #姓名# = [cd]]", "[col1 where #姓名# = {cd}]" };
    Regex reg = new Regex(@"^\[(?<o>(sum|count|max|min|last|first)\()?[^()\s]+(?(o)\))\s*(where\s*(\([^()]+\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\([^()]+\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)|'[^']*'))(\s*(and|or)\s*(\([^()]+\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\([^()]+\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)|'[^']*')))*)?\s*\]$", RegexOptions.IgnoreCase);
    foreach (string s in test)
    {
        if (reg.IsMatch(s.Trim()))
            richTextBox1.Text += s + " : 允许!\n";
        else
            richTextBox1.Text += s + " : 不允许!\n";
    }
    //输出
    [sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#] : 允许!
    [col1] : 允许!
    [col1 where (col2 = '01' or col3 > 0)] : 允许!
    [sum(col1)] : 允许!
    [sum(col1) where col4 <>'02'] : 允许!
    [sum(tab1.col1)] : 允许!
    [tab1.col1] : 允许!
    [tab1.col1 where col5 = #cola#] : 允许!
    [sum(col1) where '姓 名'='c d'] : 不允许!
    [sum(col1) where 姓 名=c d] : 不允许!
    [] : 不允许!
    [abs(col1)] : 不允许!
    [sum(tab1.col1) where ((col2 = '01' or col3 > 0) or col4 <>'02') and col5 = #cola#] : 不允许!
    [col1 where '姓 名'='c d'] : 不允许!
    [col1 where 姓 名=c d] : 不允许!
    [col1 where 姓名=cd] : 允许!
    [col1 where 姓名=1cd] : 不允许!
    [col1 where 姓名 = 'c d.e'] : 允许!
    [col1 where #姓名# = $cd$] : 允许!
    [col1 where 姓名 = #cd#] : 允许!
    [col1 where #姓 名# = #1cd#] : 不允许!
    [col1 where #_姓名# = #cd#] : 不允许!
    [col1 where #姓名# = [cd]] : 不允许!
    [col1 where #姓名# = {cd}] : 不允许!
    带()嵌套规则的
    string[] test = new string[] { "[sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#]", "[col1]", "[col1 where (col2 = '01' or col3 > 0)]", "[sum(col1)]", "[sum(col1) where col4 <>'02']", "[sum(tab1.col1)]", "[tab1.col1]", "[tab1.col1 where col5 = #cola#]", "[sum(col1) where '姓 名'='c d']", "[sum(col1) where 姓 名=c d]", "[]", "[abs(col1)]", "[sum(tab1.col1) where ((col2 = '01' or col3 > 0) or col4 <>'02') and col5 = #cola#]", "[col1 where '姓 名'='c d']", "[col1 where 姓 名=c d]", "[col1 where 姓名=cd]", "[col1 where 姓名=1cd]", "[col1 where 姓名 = 'c d.e']", "[col1 where #姓名# = $cd$]", "[col1 where 姓名 = #cd#]", "[col1 where #姓 名# = #1cd#]", "[col1 where #_姓名# = #cd#]", "[col1 where #姓名# = [cd]]", "[col1 where #姓名# = {cd}]" };
    Regex reg = new Regex(@"^\[(?<o>(sum|count|max|min|last|first)\()?[^()\s]+(?(o)\))\s*(where\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(op)(?!))\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(op)(?!))\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)|'[^']*'))(\s*(and|or)\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(op)(?!))\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)\s*(=|<>|>|is|>=|<=|like|in|not\s+in)\s*(\((?>((?<op>)\(|(?<-op>)\)|(?:(?![()]).))*)(?(op)(?!))\)|(?<p>[#$])?(?![_0-9])[a-zA-Z0-9\u4e00-\u9fa5]+(?(p)\k<p>)|'[^']*')))*)?\s*\]$", RegexOptions.IgnoreCase);
    foreach (string s in test)
    {
        if (reg.IsMatch(s.Trim()))
            richTextBox1.Text += s + " : 允许!\n";
        else
            richTextBox1.Text += s + " : 不允许!\n";
    }
    //输出
    [sum(tab1.col1) where (col2 = '01' or col3 > 0) and col4 <>'02' and col5 = #cola#] : 允许!
    [col1] : 允许!
    [col1 where (col2 = '01' or col3 > 0)] : 允许!
    [sum(col1)] : 允许!
    [sum(col1) where col4 <>'02'] : 允许!
    [sum(tab1.col1)] : 允许!
    [tab1.col1] : 允许!
    [tab1.col1 where col5 = #cola#] : 允许!
    [sum(col1) where '姓 名'='c d'] : 不允许!
    [sum(col1) where 姓 名=c d] : 不允许!
    [] : 不允许!
    [abs(col1)] : 不允许!
    [sum(tab1.col1) where ((col2 = '01' or col3 > 0) or col4 <>'02') and col5 = #cola#] : 允许!
    [col1 where '姓 名'='c d'] : 不允许!
    [col1 where 姓 名=c d] : 不允许!
    [col1 where 姓名=cd] : 允许!
    [col1 where 姓名=1cd] : 不允许!
    [col1 where 姓名 = 'c d.e'] : 允许!
    [col1 where #姓名# = $cd$] : 允许!
    [col1 where 姓名 = #cd#] : 允许!
    [col1 where #姓 名# = #1cd#] : 不允许!
    [col1 where #_姓名# = #cd#] : 不允许!
    [col1 where #姓名# = [cd]] : 不允许!
    [col1 where #姓名# = {cd}] : 不允许!
    每天只能晚上上网,所以楼主一定要把问题描述清楚,最好是给出所有可能出现情况的实例和结果哈
    另外说明一下有没有()嵌套的情况,没有就不用两个都写了
      

  10.   

    这个帖子接了,不过还有后续问题,root_大侠如果看到了这贴,请到新帖帮我解答,由衷的对root_表示感谢:
    http://topic.csdn.net/u/20081217/15/26de5cd3-b7d5-4c1d-a3d3-9b88d1efb474.html