mysql1 = "select count(*) as xiaoxing from FS1701 where F_ZF > " & rs(12) & " and  B_KH = '" & Text1.Text & "'"
rs1.Open mysql1, conn, adOpenKeyset, adLockPessimistic
这句话对不对????
可否用and

解决方案 »

  1.   

    使用UNION时,各选择列列数必须相等,而且各对应列类型必须相同
      

  2.   

    mysql1 = "select count(*) as xiaoxing from FS1701 where F_ZF > " & rs(12) & " and  B_KH = '" & Text1.Text & "'"
    rs1.Open mysql1, conn, adOpenKeyset, adLockPessimistic
    应该没什么问题,但是要注意" & rs(12) & " ,如果是数值型则不会出错,但如果是字符型就不一定对,应再在两旁加上一对单引号。
      

  3.   

    mysql = "select * from FS1701  where B_KH = '" & Text1.Text & "' union select * from FS1702 where B_KH = '" & Text1.Text & "' union select * from FS1711 where B_KH = '" & Text1.Text & "'"
    这个已成功可是我想找出他能排第几名时和与他分数一样的一共有多少个时不成功,但不出错:
    mysql1 = "select count(*) as xiaoxing from FS1701 where F_ZF > " & rs(12) & "and F_KH='"&rs(0)&"'union select count(*) as xiaoxing from FS1702 where F_ZF > " & rs(12) & " and F_KH='"&rs(0)&"'union  select count(*) as xiaoxing from FS1711  where F_ZF > " & rs(12) & " and F_KH='"&rs(0)&"'"
    mysql2 = "select count(*) as likeme from FS1701 where F_ZF = " & rs(12) & " and F_KH='"&rs(0)&"'union select count(*) as likeme from FS1702 where F_ZF = " & rs(12) & " and F_KH='"&rs(0)&"' union select count(*) as likeme from FS1711  where F_ZF = " & rs(12) & " and F_KH='"&rs(0)&"'"