I have a long list of company names, but I only want results in which the result set will return companies starting with the letters AE.
Is it possible?
Try to use LIKE
LIKE
SELECT * FROM tableName WHERE CompanyName LIKE 'A%' OR CompanyName LIKE 'B%' OR CompanyName LIKE 'C%' OR CompanyName LIKE 'D%' OR CompanyName LIKE 'E%'
or REGEXP
SELECT * FROM tableName WHERE CompanyName REGEXP '^[A-E]';
other (s)
You can (also) do this with a simple string comparison;
SELECT * FROM Companies WHERE CompanyName >= 'a' AND CompanyName < 'f'; -- to be sure to get _all_ companies on 'E'
Simple SQLfiddle .
Company names starting with A , E with LEFT . If you need to finish, you can also use RIGHT .
A
E
LEFT
RIGHT
SELECT * FROM YOURTABLE WHERE LEFT(CompanyName,1) IN ('A', 'E') ;
SELECT * FROM mytable WHERE company_name < 'F';
SELECT name FROM TABLE_NAME WHERE name BETWEEN 'a' AND 'e'
OR
SELECT Name FROM Employees WHERE Name REGEXP '^[A-E].*$'