I have a query that allows users to seach by the first letter of a list. I would like for them to search by numbers if there are any in the list.
Current code:
SELECT FROM WHERE field LIKE '$letter%'
The letter is very easy (because it is one letter) There are 10 numbers (0-9).
Any thoughts?
Select like number
Moderator: General Moderators
-
coreycollins
- Forum Commoner
- Posts: 67
- Joined: Sun Feb 01, 2004 1:04 pm
- Location: Michigan
No. So I have a list of names. Users can filter the list based on letters. So show all names that start with the letter c.
I have that part down. However I have another list where they might be needing to filter by numbers. So rather than clicking on A-Z, they could click on a # sign and the list would be filtered to show only results that start with a number.
I have that part down. However I have another list where they might be needing to filter by numbers. So rather than clicking on A-Z, they could click on a # sign and the list would be filtered to show only results that start with a number.
-
coreycollins
- Forum Commoner
- Posts: 67
- Joined: Sun Feb 01, 2004 1:04 pm
- Location: Michigan
Oh ok that makes sense now.
This is the only way I can come up with how to do what you want right now. There is probably a better way but this is all I could come up with right now and this should work for you.
This is the only way I can come up with how to do what you want right now. There is probably a better way but this is all I could come up with right now and this should work for you.
Code: Select all
SELECT foo FROM bar WHERE foo LIKE '1%' or '2%' or '3%' or '4%' or '5%' or '6%' or '7%' or '8%' or '9%' or '0%'here is another way:
Code: Select all
SELECT foo FROM bar WHERE left(foo,1) between '0' and '9'-
coreycollins
- Forum Commoner
- Posts: 67
- Joined: Sun Feb 01, 2004 1:04 pm
- Location: Michigan