Reputation: 59
I have a simple table with names, some beginning with a letter and some beginning with a number. I am trying to filter out the names that start with a number, and only select the names that start with a letter of the alphabet.
Here are a few of my attempts, which have failed to produce the desired results:
SELECT name
from subjects
WHERE name LIKE ('A%') AND
WHERE name LIKE ('B%') AND
WHERE name LIKE ('C%')...;
SELECT name
from subjects
WHERE name LIKE ('A%', 'B%', 'C%', ...);
SELECT name
from subjects
WHERE name LIKE ('A%') AND ('B%') AND ('C%') ...;
Thank you, in advance, for your help. I appreciate it very much. Stack Overflow has been my savior so many times as I am learning to program with PHP and MySQL. Lori
Upvotes: 0
Views: 104
Reputation: 2017
Try Regexp:
SELECT name
FROM subjects
WHERE name
REGEXP '[A-Za-z]'
Upvotes: 0
Reputation: 6876
the problem you are having is you have included multiple wheres. Simply remove them
SELECT name
from subjects
WHERE name LIKE ('A%') AND
name LIKE ('B%') AND
name LIKE ('C%')...;
Upvotes: 0