문제

i want to get like wildcard query to search by second word

here few column data

sea food
food restaurant
Chinese food

if i search for "foo". it should return

sea food
Chinese food

how can i do that in MySQL

도움이 되었습니까?

해결책 2

use regexp in your sql query .. something like

select * from table where col regexp '^[A-Za-z]+\s(foo).*$'

EDIT

used your table .. try this ..

select id,col from food where col regexp '^[A-Za-z]+ (foo)'

다른 팁

How about:-

select * from table where food_name like '% foo%'

Use Below query. This will help in your case.

select column-name-list from table-name 
where right(your-desired-column-name,4) = 'food';

Here is one way of doing it

select * from
test
where 
substring_index(food_name,' ',-1) like '%foo%'
AND 
(
   LENGTH(food_name) - LENGTH( substring_index(food_name,' ',-1)) > 0
 )
;

DEMO

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