简体   繁体   中英

need to add to this LIKE clause on IBM i SQL

I have a VIEW with these WHERE Conditions. I would like to add another type on the 3 rd 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?

ASTDTA.ICPRTMIA.IARCC9='ACS' AND        
ASTDTA.OEINDLID.IDCOM#='001' AND        
ASTDTA.OEINDLID.IDPRT# LIKE 'ACS%' AND  
ASTDTA.ADRESSAD.ADSFX# =                
SUBSTR(ASTDTA.OEINDLID.IDGRC#,9,3       

Use an OR condition:

ASTDTA.ICPRTMIA.IARCC9='ACS' AND        
ASTDTA.OEINDLID.IDCOM#='001' AND        
(ASTDTA.OEINDLID.IDPRT# LIKE 'ACS%' OR ASTDTA.OEINDLID.IDPRT# LIKE 'FR%') AND  
ASTDTA.ADRESSAD.ADSFX# =                
SUBSTR(ASTDTA.OEINDLID.IDGRC#,9,3       

If you've only got a small handful of patterns, then use JamesA's answer. But if you find you have a bunch, then put your patterns in a table, or a temp table, or possibly just a common table expression with a values statement in it. Let's call it RULES. Now you can join to it, and say

ASTDTA.OEINLID.IDPRT# LIKE RULES.PATTERN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM