Reputation: 21
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
Reputation: 60262
Try something like the following:
SELECT * FROM mytable
WHERE SUBSTR(firstName, 1, 1) = 'N'
AND SUBSTR(lastName, 1, 1) = 'K';
Upvotes: 2
Reputation: 223227
What about regular Expression ?
select * from table1 where regexp_like ( firstName, '^N*');
select * from table1 where regexp_like ( lastName, '^K*');
Upvotes: 1
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