letter17
letter17

Reputation: 11

MySQL - Select first letter including articles (a, an, the)

So I understand how to find results if I only want to find the beginning of a column. Like:

select * from locations where (loc_name like 'C%') 

or

select * from locations where (loc_name REGEXP '^[C]') 

What I need to figure out is how to do the same thing, but include anything that is the C. For example, a place called The Castle or The Park Tavern or anything like that.

When clicking on the letter on a web page, the results should come up with anything with that letter or THE letter.

Upvotes: 1

Views: 34

Answers (1)

Josue Gomez
Josue Gomez

Reputation: 31

Thats easy if you're gonna look for C or The C just write this:

Select * from locations where loc_name like 'C%' or upper(loc_name) like 'THE C%';

try it

Upvotes: 3

Related Questions