springjdbc like fuzzy query, Spring namedparameterjdbctemplate like query ,
Springjdbc named parameter like Fuzzy query, namedparameterjdbctemplate like fuzzy query
>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>
? Copyright Sweet Potato Yiu July 20, 2017
http://www.cnblogs.com/fanshuyao/
When Springjdbc uses a named template class (Namedparameterjdbctemplate) for a like fuzzy query, how do I set it?
Method One: Set in the SQL statement (%)
Java code
- SELECT * from Jo_user WHERE 1=1 and username like '% ': username '% '
- : There must be a space on both sides of username
- If: Username no space on both sides of the query is not data, as follows:
- SELECT * from Jo_user WHERE 1=1 and username like '% ': username'% '
- Left Blur Query
- SELECT * from Jo_user WHERE 1=1 and username like '% ': username
- Fuzzy query on the right
- SELECT * from Jo_user WHERE 1=1 and username like:username '% '
Method Two: Set (%) in the value of the parameter, the query SQL statement is just a named parameter
such as "%" + Username + "%"
SQL is as follows:
Java code
- SELECT * from Jo_user WHERE 1=1 and username Like:username
Both of the above methods have been tested and can be used with confidence.
After testing, the following is not possible (add a double vertical line).
Java code
- SELECT * from article WHERE title like '% ' | |: TITLE | | '% '
>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>
? Copyright Sweet Potato Yiu July 20, 2017
http://www.cnblogs.com/fanshuyao/
Springjdbc like fuzzy query, Spring namedparameterjdbctemplate like query