当前位置: 动力学知识库 > 问答 > 编程问答 >

SQL equals like error

问题描述:

I have a database consisting of header files. E.g: <iostream>,<ctype.h> etc. When my query is:

select * from hf_list where hf = '<iostream>'

it returns an empty set while

select * from hf_list where hf like '%<iostream>%'"

gets the correct result even though the entry does not have any extra characters other than <iostream>.

Why is this happening?

网友答案:

If you are saying '%%' you are basically saying give me everything checkout below code

;with sam as (

select ' <iostream> ' as col1
union 
select 'sam' as col1
)

select * from sam where col1 like '%<iostream>%'

If you would like to check if you have blank data do this select * from hf_list where rtrim(ltrim(hf)) = 'iostream'

分享给朋友:
您可能感兴趣的文章:
随机阅读: