Skip to content
Advertisement

SQLDeveloper – Check for a column within another column

I am currently trying to query if a Last_Name column has the suffix added to the end of a Last_Name.

I have a Suffix Table(SUFFIX) which stores the available suffixes (I, II, III, IV, V, Jr., Sr.) however I am running into trouble when I have performed the below query as it shows all the last names even if it does not contain the SUFFIX at then end of LAST_NAME column.

What I am trying to make is the following: If Suffix = IV and last name is SmithIV (contains the suffix)at the end of the last name to display on my results.

For some reason the suffix was added to some last names and I am trying to determine how many are affected.

Advertisement

Answer

This is how I understood the question.

Lines #1 – 15 represent sample data; interesting part are lines #19 – 21 which select the last “several” characters from the last name, where “several” equals length of the suffix itself.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement