[英]I have to filter records by retrieving from SQL table. I want the values in the same field in my table column in sql to not show again
[英]My table contains a column name title. I want to sql search filter male and female from title column
我有一個 sql 數據庫表名法。 其中有一個列名標題。 我想使用 LIKE 查詢來實現搜索操作。 但是當我從標題欄中搜索男性時,它也會返回女性。 通知我的標題列包含多個單詞的一件事。 但我不想看到那些包含女性詞的行。 我對 LIKE 參數使用了通配符。
SELECT * FROM `laws` WHERE title LIKE "male"
問題是你需要像我讀到的那樣使用你需要使用:
SELECT * FROM law WHERE title = 'male';
您是否需要像我一樣使用:
SELECT * FROM law WHERE title like 'male%';
當然,如果您正在尋找以下記錄:男性 25 歲。
您需要在文本中包含男性並明確排除女性。
如果你想要第二行,你需要更復雜的查詢
CREATE TABLE laws (title varchar(50))
INSERT INTO laws VALUEs ('Only for male partitipents'),('male and female partitipents'),('No more female partitipents in this law')
SELECT * FROM `laws` WHERE title LIKE '%male%' AND title NOT LIKE '%female%'
| 標題 | |:-------------- | | 僅限男性參加者|
db<> 在這里擺弄
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.