Forum Discussion

leo82's avatar
leo82
Cloud Apps
02-02-2024

Help with Escaping Underscores in LIKE Clause in Sisense SQL Editor

Hello Sisense Community,

I've encountered an issue with using the LIKE clause in the Sisense SQL editor, specifically when trying to escape underscores (_) in my search pattern. I'm attempting to filter project names that start with "E_" from a table named [Workspace_data]. However, the standard SQL ESCAPE keyword seems not to be recognized, leading to an error.

Here's the query I initially tried:

 

SELECT a.[workspc_nm]
FROM [Workspace_data] a
WHERE a.[workspc_nm] LIKE 'E\_%' ESCAPE '\'

 

The error message returned by Sisense is as follows:

 

1 out of 1 errors
Line 3 Column 33
Found 'ESCAPE' but expected '<End of Expression>'.

 

Based on the SQL cheat sheet provided by Sisense, there's guidance on various operators and comparisons, but I couldn't find specific mention of handling escape characters within the LIKE clause, especially for escaping underscores.

I've attempted to adjust the query by omitting the ESCAPE clause

 

select a.[workspc_nm]
from [Workspace_data] a
where a.[workspc_nm] LIKE 'E\_%'

 

This does not throw any error, however it gives me only partial results. In my attempt to filter project names that start with "E_"  the above query filters all projects, even project names like 'Eagle', or  'Elephant'. I want only names that follow the pattern 'E_Team ABC' 'E_Team XYZ' etc

Could anyone provide insights or guidance on the correct way to escape special characters like underscores in Sisense's SQL editor? Is there an alternative approach or syntax that Sisense supports for this kind of pattern matching?

Any advice or examples from your own experiences would be greatly appreciated. Thank you in advance for your help!

Best regards,

4 Replies

Replies have been turned off for this discussion