SQL dizesi maç numaraları, değişen uzunluk

0 Cevap php

I am looking up which exchange services which telephone numbers, from a table of fragmentary numbers that show which exchange services them. So my table contains, for example:

id      |exchcode   |exchname       |easting|northin|leadin     |
-----------------------------------------------------------------
12122   |SNL/UC     |SANDAL        |43430   |41306  |1924240    |
12123   |SNL/UC     |SANDAL        |43430   |41306  |1924241    |
881     |SNL/UD     |SANDAL      |43430 |41306  |1924249    |
2456    |BD/BCC/1   |BRADFORD CABLE |41627  |43262  |192421     |
4313    |NEY/UB     |NORMANTON      |43847  |42289  |192422     |
12124   |SNL/UC     |SANDAL         |43430  |41306  |192425     |
9949    |OBE/UB     |HORBURY OSSETT  |42857 |41971  |192428     |
9987    |OBE/UB     |WAKEFIELD       |42857 |41971  |1924       |

(Üzgünüm, biraz çöp biçimlendirme)

leadin is the leading part of the phone number I have to match (stored as a VARCHAR, not a number)

And I am supplied with a phone number 1924283777 (not real) how do I query to get the best match from the above table (It should pick exchange id 9949), or do I deal with it in code after I've done the query (php)

tl; dr: sütun leadin değerleri için değişken uzunluk, uzun leadin daha bir dizi ile iyi bir maç istiyoruz.

0 Cevap