Focal Point
Like operator

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9671067892

September 09, 2008, 05:09 AM
<B_B>
Like operator
Hi,
I need to give a where clause using 'like' with 2 string values.
e.g. w
where column_name like 'abc' and 'xyz'

What would be the right syntax?
September 09, 2008, 05:30 AM
<JG>
quote:
where column_name like 'abc' and 'xyz'


It totally depends on where you want the comparison

WHERE column_name LIKE 'abc%_' OR 'xyz%_'

I'm sure for such a well documented basic WebFocus process
learning to read would help you a great deal in your tasks.
September 10, 2008, 05:41 PM
Waz
I agree with JG

As Tony A has mentioned many times the link at the top right of the page will get you to the documentation.

Although I would code
WHERE column_name LIKE '%abc%'
AND column_name LIKE '%xyz%'


Depending on what you mean by like and the values. Does it contain abc and xyz?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

September 11, 2008, 08:53 AM
GinnyJakes
Tony is correct. It needs to be an OR not an AND. Otherwise you won't get any data.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
September 11, 2008, 09:27 AM
<JG>
Ginny,

Tony is correct, IF you want the column to contain BOTH 'abc' AND 'xyz'

However if you require either/or then 'OR' is required, The % at the the begining or/end
depends on the postion of the search string.

quote:
It totally depends on where you want the comparison


Should perhaps have been Where and What you want the comparison to be.
September 11, 2008, 05:32 PM
Waz
The issue with getting no data comes down to how you code the WHERE clause

TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY LIKE '%E%' AND '%G%'
END

Produces an error

TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY LIKE '%E%' OR '%G%'
END

Produces a list of ENGLAND, W GERMANY, FRANCE.

But if you use
TABLE FILE CAR
PRINT COUNTRY
WHERE COUNTRY LIKE '%E%' AND COUNTRY LIKE '%G%'
END

You get ENGLAND, W GERMANY


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!