簡體   English   中英

使用通配符的搜索功能

[英]Search functionality using wild card

我正在研究 seach 函數,其中請求來自帶有通配符的前端,並根據請求輸出所需的結果。

假設我們在 DB 中有一個 Name 列,其中包含一些記錄:

Name
---------
political party Delhi, IN (ruling)
political party Mumbai, IN (ruling)
political party Kerala, IN (not ruling)
political party Goa, IN (ruling)

 Now from JSP page request is coming as *Del*ruling* (or request could come just as *Del*) and outcome should be: political party Delhi, IN (ruling). I spent few days but could not find how to implement this functionality. Any guidance will be highly appreciated.

MySQL 支持通配符。 它們由%字符表示並在LIKE語句中使用。 因此,只需將所有 '*' 替換為 '%' 就可以了!

SELECT *
FROM articles
WHERE body LIKE '%Del%ruling%'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM