user1302503
user1302503

Reputation: 21

Query table by string matching without using LIKE?

How can I query a table where first name starts with 'N' and last name starts with 'K' without using like?

Upvotes: 2

Views: 138

Answers (3)

Jeffrey Kemp
Jeffrey Kemp

Reputation: 60262

Try something like the following:

SELECT * FROM mytable
WHERE SUBSTR(firstName, 1, 1) = 'N'
AND   SUBSTR(lastName,  1, 1) = 'K';

Upvotes: 2

Habib
Habib

Reputation: 223227

What about regular Expression ?

select * from table1 where regexp_like ( firstName, '^N*');
select * from table1 where regexp_like ( lastName, '^K*');

Upvotes: 1

Scalino Corleone
Scalino Corleone

Reputation: 11

you might try with > and < operators

e.g.:

WHERE NAME >= 'N' AND NAME < 'O'

but I don't guarantee you get each and every letter you would expect (especially with accentuated characters if any)

Scal

Upvotes: 1

Related Questions