Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

byrnel0586
Not applicable

Using 'Like' in SQL 'Where' statement

Hi,

I am using the below script and the "LOB_ID" Like '7*' piece is returning no results when I know there should be. Can someone please let me know what I may be doing wrong?

SQL SELECT

"EFF_DT",

"PCP_ID" AS mms_PCP_ID,

"VEND_ID" AS mms_VEND_ID,

"LOB_ID" AS mms_LOB_ID,

"MEM_ID" AS mms_MEM_ID

FROM DWDB.DBO."DW_MEM_MONTH"

WHERE "EFF_DT" >= 42979 AND "EFF_DT" <= 43008 AND "LOB_ID" LIKE '7*';

Thanks!!

1 Solution

Accepted Solutions
sunny_talwar
Not applicable

Re: Using 'Like' in SQL 'Where' statement

Try with % for WildCard

SQL SELECT

"EFF_DT",

"PCP_ID" AS mms_PCP_ID,

"VEND_ID" AS mms_VEND_ID,

"LOB_ID" AS mms_LOB_ID,

"MEM_ID" AS mms_MEM_ID


FROM DWDB.DBO."DW_MEM_MONTH"

WHERE "EFF_DT" >= 42979 AND "EFF_DT" <= 43008 AND "LOB_ID" LIKE '7%';

3 Replies
sunny_talwar
Not applicable

Re: Using 'Like' in SQL 'Where' statement

Try with % for WildCard

SQL SELECT

"EFF_DT",

"PCP_ID" AS mms_PCP_ID,

"VEND_ID" AS mms_VEND_ID,

"LOB_ID" AS mms_LOB_ID,

"MEM_ID" AS mms_MEM_ID


FROM DWDB.DBO."DW_MEM_MONTH"

WHERE "EFF_DT" >= 42979 AND "EFF_DT" <= 43008 AND "LOB_ID" LIKE '7%';

byrnel0586
Not applicable

Re: Using 'Like' in SQL 'Where' statement

Thanks, Sunny! I had been reading everywhere that SQL syntax isn't supported in the script so I didn't even think to try that. It is working perfectly now.

sunny_talwar
Not applicable

Re: Using 'Like' in SQL 'Where' statement

Actually anything you have after SQL SELECT needs to have SQL Syntax because if you don't (and use QlikView syntax) it won't work. Anything after SQL SELECT is sent to the database for querying and needs the SQL syntax.