On 22 Sep 2013 16:33, Hoteltravelfundotcom wrote:
I have a VIEW with these WHERE Conditions. I would like to add
another type on the 3rd line. Here I want also those rows with like
as "FR" is there a way to sort of have such a group like that under
the LIKE clause?
AND ASTDTA.OEINDLID.IDPRT# LIKE 'ACS%'
AND ASTDTA.ADRESSAD.ADSFX# = SUBSTR(ASTDTA.OEINDLID.IDGRC#,9,3)
I am unsure if I interpreted what was attempted to be expressed as
the desired effect, but I offer [given my interpretation]:
AND ( ASTDTA.OEINDLID.IDPRT# LIKE 'ACS%'
OR ASTDTA.OEINDLID.IDPRT# LIKE 'FR%'
AND ASTDTA.ADRESSAD.ADSFX#=SUBSTR(ASTDTA.OEINDLID.IDGRC#, 9, 3)
P.S. The use of correlation identifiers protects against excessive
changes that would be required given any change in a schema or table
name were required; that also IMO makes the SQL much more readable.
Also note that a space was added after each comma in the SUBSTR scalar
to make the expression functional globally. FWiW the above WHERE-clause
rewritten using some correlation names makes the predicates fit on a
line with fewer characters and would allow the entire WHERE-clause to
remain unchanged when the table or library name for the table-reference
had changed, given the correlation-name was left unchanged:
AND ( OEI.IDPRT# LIKE 'ACS%'
OR OEI.IDPRT# LIKE 'FR%'
AND ADR.ADSFX#=SUBSTR(OEI.IDGRC#, 9, 3)