關於記錄的模糊搜尋

2021-04-23 17:38:35 字數 1116 閱讀 3160

*模糊搜尋的建立

*建立乙個產品資訊表,設定產品序號字段

*設定搜尋輸入文字框text2

*設定提示資訊文字框text3

*設定搜尋命令按鈕,**如下:

public j,i,e,x&&宣告全域性變數

j=0i=1

*字串處理

m=thisform.text2.text&&取字串

e=alltrim(m)&&刪除左右空格

x=len(e)&&測試字串長度

f=left(產品資訊.產品序號,x)

*查詢記錄

if x>0

locate for left(產品資訊.產品序號,x)=e&&找到符合條件的第一條記錄

if found()=.t.&&找到記錄

a=recno()&&獲得當前記錄數

endif

*查詢所有符合條件的記錄

do while .not.eof()&&繼續查詢直到尾記錄

if found()=.t.

j=j+1&&記錄總數

endif

continue

enddo

endif

*後續處理

if x>0 and j=1

q="找到記錄在第"+ltrim(str(i))+"條。"&&str()轉化為字串,ltrim()刪除字串左邊的空格

go a

endif

if x>0 and j>1

q="共計找到"+ltrim(str(j))+"條記錄。"&&str()轉化為字串,ltrim()刪除字串左邊的空格

thisform.command3.enabled=.t.

go a

endif

if x>0 and j=0

q="沒有找到記錄。"

go 1&&返回到第一條記錄

endif

if x=0

q="請輸入產品序號!"

go 1&&返回到第一條記錄

endif

thisform.text3.value=q

thisform.refresh&&重新整理當前窗體

thisform.text2.setfocus&&文字框text1獲得焦點

MySQL的模糊搜尋

第一時間我馬上想到了關鍵字like 1.1.所要查詢的字段中包含特定 字元,但不確定其位置,使用兩個 包 起來select from phone where provider like 1.2.能夠確定要查字段的結尾,則如下 select from student where name like 聰...

zTree模糊搜尋

根據搜尋的值重新顯示整個ztree 1 輸入框 2 js chatgroupserarchbtn click function function doqueryalg4name value treeobj.shownodes nodelist 指定被顯示的節點 json 資料集合 if value ...

ztree模糊搜尋

1 方法 function 載入樹方法和事件 function searchdepart newdepartcontroller.do?gettreedata datatype json data success function list var setting check view data c...