|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
I have a database which is searchable by zip code and I want to also make it searchable by area code and prefix.
I have the form set up where the user can enter an area code and a prefix. In the database one of the fields is 'Phone'. Question: Is it possible to select the records in the database by comparing the form input to only the first 6 digits of the 'phone' field?? Any help is appreciated. Thanks, jim |
|
#2
|
|||
|
|||
|
Have you tried using the LEFT function?
LEFT(string, length) returns length characters from the start (left end) of string. So you could query: SELECT * FROM yourtable WHERE LEFT(phone, 6) = 'yoursearchterm'; |
|
#3
|
|||
|
|||
|
That will do it.
Almost sounds logical doesn't it? 8-) Thanks, Jim |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > searching partial field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|