the-miz
asked on
php mysql search
I have written code to list all companies in our database alphabetically. I have quick links at the top from A-Z and also have one other link that is suppose to get all companies that start with a number or special character. Does anyone know the SELECT command in MySQL that can search all the companies and list them that begin with a number or special character. Basically a list of all companies that DO NOT start with a letter.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think the cleaner way would be to alter the table. That is what I would probably do.
Something like :
SELECT * FROM tableName WHERE NOT columnToCheck REGEXP '[A-Za-z0-9]';
That WHERE NOT REGEXP might need to be something like '[A-Za-z]{1}.*?' to find the companies like 3-M that start with numbers. Not quite sure about that regex syntax in MySQL. I still think I might change the table to add a selection column. It would depend on the weight of the table scan that would result from the SELECT .. WHERE NOT.
Best to all, ~Ray
Best to all, ~Ray
ASKER