首页  >  文章  >  电脑教程  >  执行模糊匹配的SQL数据库查询

执行模糊匹配的SQL数据库查询

PHPz
PHPz转载
2024-01-23 10:30:05892浏览

执行模糊匹配的SQL数据库查询

Sql Server 环境,如果环境不对, 自己参考思路去修改吧

select * into #temp1 from table1 where len(col1) > 5 and len(col2) > 5

select * into #temp_end from #temp1 where 1=3

Declare @i int,@ii int

Declare @uid int,@col1 varchar(255),@col2 varchar(255)

Declare Fetch_Query_Cursor cursor for select UID,col1,col2 from #temp1

Open Fetch_Query_Cursor

Fetch Next From Fetch_Query_Cursor into @uid,@col1,@col2

while @@Fetch_status = 0

begin

select @i = 1,@ii=0

while @i

begin

if charindex(substring(@col1,@i,1),@col2) > 0

select @ii = @ii+1

select @i = @i+1

end

If @ii >=5

Insert into #temp_end select * from #temp1 where Uid = @uid

Fetch Next From Fetch_Query_Cursor into @uid,@col1,@col2

end

Close Fetch_Query_Cursor

Deallocate Fetch_Query_Cursor

Select * from #temp_end

Drop table #temp1

Drop table #temp_end

c语言怎样实现对数字模糊查找

字符串模糊查询,主要是输入不完全的信息进行查找,即每次查找的是待查询的内容中是否含有输入的内容,如果有,则表e68a84e8a2ade79fa5e9819331333363376434示找到了。下面详细的说明下模糊查询的实现方法,代码如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

#include

#include

#include

int main(int argc, const char * argv[])

{

char str[] = "hello welcome to china

以上是执行模糊匹配的SQL数据库查询的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:docexcel.net。如有侵权,请联系admin@php.cn删除