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
WazI 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?
September 11, 2008, 08:53 AM
GinnyJakesTony is correct. It needs to be an OR not an AND. Otherwise you won't get any data.
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
WazThe 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