如何在hibernate和SQL中的字符串查询中强调下划线? [英] How to escape underscore in the string query in hibernate and SQL?

查看:79
本文介绍了如何在hibernate和SQL中的字符串查询中强调下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL 查询中给出的 _ (下划线)不符合。



示例:

  SELECT * FROM employee WHERE NAME LIKE'%k_p%'; 

这与包含 k_p $ b $ p有人可以帮助我们在 SQL 以及休眠?感谢。

解决方案

您是否尝试过转义它:

  SELECT * FROM employee WHERE NAME LIKE'%k \_p%'; 

\ _ 而不只是 _


The _ (underscore) given in the SQL query is not honored.

Example :

SELECT * FROM employee WHERE NAME LIKE '%k_p%';

This matches and brings many rows apart from rows which contain k_p

Could someone please assist on how to achieve this in SQL and also in Hibernate? Thanks.

解决方案

Have you tried escaping it:

SELECT * FROM employee WHERE NAME LIKE '%k\_p%';

\_ instead of just _.

这篇关于如何在hibernate和SQL中的字符串查询中强调下划线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆