How do i write a sql query with user input and wildcards
Posted
by acidzombie24
on Stack Overflow
See other posts from Stack Overflow
or by acidzombie24
Published on 2010-03-22T22:57:10Z
Indexed on
2010/03/22
23:01 UTC
Read the original article
Hit count: 454
Usually i write my where statements as WHERE key=@0
then add a param. Now i would like the user to specific a few letters such as 'oat' and would like to stick wildcards around it %oat%
which matches 'coating'. So how do i write the query so wildcards are around the user input (the 'seachword').
Now lets take it a step further. I would not like the user to write % so he cannot do blah%ing. Perhaps % is part of the sentence (or it could be flat out illegal but i prefer it be part of the sentence). How do i put my wildcards around a word or sentence and disallow the user from putting the wildcard between his words? (and preferably make % part of the sentence)
C# ado.net sql/sqlite
© Stack Overflow or respective owner