简体   繁体   English

Oracle 12g中不区分大小写的搜索

[英]Case Insensitive search in oracle 12g

I have count query, which should counts the total number of records corresponding to the displayed list, I am using like to filter out the record by matching the freetext, record exists in the table but still, query count is 0. 我有计数查询,它应该计算与显示的列表相对应的记录总数,我使用的like通过匹配自由文本来过滤出记录,表中存在记录,但查询计数仍为0。

What I did, I supplied the text abc in the search box, but inside table the data is stored in the uppercase i,e ABC . 我所做的是,我在搜索框中提供了文本abc ,但是在表内部,数据存储在大写字母i ABC中

I want a method for case insensitive search. 我想要一个不区分大小写的搜索方法。

QUERY: 查询:

SELECT
    COUNT(calender_id)
FROM
    calender s
    LEFT JOIN userdetail uu ON update_by = uu.user_id
WHERE
    calender_id = calender_id
     AND LOWER(s.details) LIKE 'Abc%'

Since you're lower ing the table's column, you should use a lowercase literal too: 由于要lower表的列,因此也应使用小写字母:

LOWER(s.details) LIKE 'abc%'
-- Here ---------------^

for the case insensitive the easiest way is using the lower or upper, I think you should modify the query in this way: 对于不区分大小写的最简单的方法是使用下层或上层,我认为您应该以这种方式修改查询:

SELECT
    COUNT(calender_id)
FROM
    calender s
    LEFT JOIN userdetail uu ON update_by = uu.user_id
WHERE
    calender_id = calender_id
     AND LOWER(s.details) LIKE 'abc%'

or 要么

SELECT
    COUNT(calender_id)
FROM
    calender s
    LEFT JOIN userdetail uu ON update_by = uu.user_id
WHERE
    calender_id = calender_id
     AND UPPER(s.details) LIKE 'ABC%'

You can try below 您可以在下面尝试

SELECT
    COUNT(calender_id)
FROM
    calender s
    LEFT JOIN userdetail uu ON update_by = uu.user_id
WHERE
    calender_id = calender_id
     AND LOWER(s.details) LIKE lower('Abc')||'%'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM