문제

EDIT: the problem came from my database configuration, case closed, thanks!

I have the following data set:

Roma
Romagnano
Romano

When I use the following LIKE statement: LIKE 'rom%'

I get:

Roma
Romagnano
Romano

However, when I use the statement LIKE 'roma%'

I get:

Romagnano
Romano

What LIKE statement should I use in my query to keep the line "Roma" in my results and keep the following result set if the search is based on "roma":

Roma
Romagnano
Romano

Should I use REGEXP instead? Many thanks

도움이 되었습니까?

해결책 2

I don't know what the exact configuration on your system is, but on SQL Fiddle the following returns all three values:

select *
from (select 'Roma' as val union all
      select 'Romagnano' union all
      select 'Romano'
     ) r
where val like 'roma%';

다른 팁

Something is your MySQL configuration seems to be different, since both the documentation and a simple SQLFiddle test say otherwise: it should work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top