简体   繁体   中英

Teradata SQL- Split a string and search for that combination in respective fields

I have a set of fixed length strings in excel. How to split the string and provide the condition in WHERE clause? I mean

eg: P0025583740005, P0025583740002, P0068377440009, P0067264370006.... the last four digits are the PIN number and the rest is the Claim number. Claim Number - P002558374; PIN - 0005

while I'm searching for these in teradata sql, I'm manually splitting the values like

SELECT * from myTable 
where (Claim_nbr = 'P002558374' and PIN='0005') 
OR (Claim_nbr = 'P002558374' and PIN='0002')

Is there a better way to do this?

SELECT * from myTable 
WHERE Claim_nbr || PIN IN ('P0025583740005', 'P0025583740002', ...) 

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