Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
karthik_192me
Starting Member
3 Posts |
Posted - 2011-05-17 : 12:23:37
|
| Hi,I am new to this forum,new bee to SQL.,my DB isdigit,name93,RAM9379,GURU937,RAVIwant to get maximum character match,like when i give 93799321205i shd get maximum match, output shd be 9379,guru,tried some how below but not getting exact output.,pl helpSELECT name,digit from MDL where LEFT('93799321205',length(digit))=digit;edit: moved to proper forum |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-05-17 : 13:55:25
|
Would this work for you? I am assuming that the digit column is of type varchar. If not you will need to cast it as varcharSELECT *FROM theTable aWHERE NOT EXISTS ( SELECT * FROM theTable b WHERE b.digit LIKE a.digit+'%' AND a.digit <> b.digit) |
 |
|
|
karthik_192me
Starting Member
3 Posts |
Posted - 2011-05-19 : 12:12:03
|
| HiThanks u very much for ur reply, i finally got the solution.,digit data type is text.SELECT digit from MDL where LEFT('9940061716',length(digit))=digit order by length(digit) desc limit 1; |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-05-30 : 07:20:00
|
| Note that this forum is for MS SQL Server. For mysql questions try at www.mysql.comMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|