光影魔术手安卓:请教sql同一表中多字段搜索问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/06 18:11:44
用vb写的,目的是在同一个表的A,B两个字段中搜索text1里的内容,text1输入的为8位-14位任意数字。
rcon.open "select * from table1 where A = 123 OR B = 456 "

抱歉,我第一次学sql,很多地方都不通,还望各位指点啊
rcon.open "select * from table1 where A = ' " & text1 & " ' OR B = ' " & text1 & " ' "
这样写好象也不对

我使用这种方法实现了
"select no,name,from 表1 where (no like '%" & Text1 & "%') or (name like '%" & Text1 & "%')"

2位的答案都有对的地方

首先、你说的是搜索也就意味着 A,B 两个字段中可能有很多内容。对不对?

那么加入你的系统支持 通配符 % 则可以这么写:

Select * from table1 where (A LIKE "%(用text1替代包括括号)%") or (B LIKE "%(用text1替代包括括号)%")

rcon.open "select * from table1 where A like '% " & text1.text & " %' OR B like ' %" & text1.text & " %' "