I'm storing telephone number (US) in 10 digit varchars. If I want to do a search on just the area code, is there a way to limit it to just the first 3 digits of the string ?
I'm trying something like this but still getting back the whole string:
select Telephone from SignUp where Left (SUBSTRING(Telephone,1,3), 3) LIKE '4%'
It's a bit unclear what you are trying to do. Are you trying to find all numbers within a 3 digit area code, i.e. numbers starting with some 3 digits? Or are you trying to find numbers with any of the three first digits equal to 4?
For the first case, area code 444:
SELECT Telephone FROM SignUp WHERE Telephone LIKE '444%';
... and for the second case, finding the digit 4:
SELECT Telephone FROM SignUp WHERE LEFT(Telephone,3) LIKE '%4%';
-- Roger
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]