2011-03-14 95 views
0

返回任何行,我有以下查询,Postgres的查询不使用like运算

Select alpha_key,name,trading_as ,typeclient from client_details where upper(trading_as) like '%TEST\\''S LOGISTICS SERVICES%' order by name ;

不返回任何行,但

Select alpha_key,name,trading_as ,typeclient from client_details where upper(trading_as) = 'TEST\\''S LOGISTICS SERVICES' order by name ;

返回一行。

回答

1

因为有两个解释,一个是分析字符串时,另一个是与LIKE比较时,您必须将两个反斜杠转义。

所以你的要求变为:

Select alpha_key,name,trading_as ,typeclient 
from client_details 
where upper(trading_as) like '%TEST\\\\''S LOGISTICS SERVICES%' 
order by name ;