2012-07-04 39 views
0

我有以下SQL Server查詢:ORDER BY在SQL Server中找到WHERE LIKE子句的位置?

SELECT area 
FROM places 
WHERE REPLACE(area,'-',' ') LIKE REPLACE('%moreto%','-',' ') 

返回以下結果:

Moreton Pinkney, Northamptonshire 
South Moreton, Oxfordshire 
North Moreton, Oxfordshire 
Moreton, Merseyside 
Moreton-in-Marsh, Gloucestershire 
Moreton Jeffries, Herefordshire 
Moreton on Lugg, Herefordshire 
Maids' Moreton, Buckinghamshire 
Moreton Corbet, Shropshire 
Moretonhampstead, Devon 

有什麼辦法,我可以訂購基礎上,發現LIKE語句的位置的結果?例如,如果有人正在輸入'moreto',那麼他們可能會從頭開始輸入單詞,而不是中間輸入單詞。

同樣,有人提到前 - 我不知道我可以通過刪除第一個通配符(%),但取得這些成果,如果有另一種方式來做到這一點,而不需要太多隻是想知道。

非常感謝。

回答