0

I am using Oracle SQL Developer. I need to find the rows where column1 starts with ‘987’ or ‘I’. Column1 is a String(18). Some sample patterns in this column include: 9(9), 9(12), and others. I am not familiar with the code to see how a column starts with certain values in Oracle SQL. Sample Code is below. Attempt below.

Code

select * from table1
where column1

Attempt Code

SELECT
 REGEXP_SUBSTR(column1,
 '987') "REGEXP_SUBSTR"
 FROM table1;
asked Jan 7, 2020 at 18:59
1
  • Are you familiar with the SQL "like" operator? Commented Jan 7, 2020 at 19:06

3 Answers 3

3

You can use a regular expression for this:

where regexp_like(column1, '^(987|I)')
answered Jan 7, 2020 at 19:37
Sign up to request clarification or add additional context in comments.

1 Comment

This one should be marked as a more convenient answer.
2

You just need to use LIKE.

select * 
from table1
where column1 like '987%' or column1 like 'I%';
answered Jan 7, 2020 at 19:05

Comments

0

CREATE TABLE hs(WH VARCHAR2(100));

SELECT * FROM hs WHERE REGEXP_LIKE(WH,'^987|^I', 'i') ORDER BY WH;

answered Jan 8, 2020 at 7:59

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.