1

I have MYSQL query that looks as below

select * from table1 where host REGEXP 'host1';

I want to execute the same query using LIKE Please suggest how it can be achieved

0

2 Answers 2

3

Try this:

select * from table1 where host LIKE '%host1%';

REGEXP 'host1' will match host1 anywhere in the string. To phrase this using the LIKE operator we need to surround host1 with wildcards.

Sign up to request clarification or add additional context in comments.

2 Comments

@Phil Based on this demo it seems that your comment is mistaken.
Seems you are correct and reality differs to expectations
0

You can try using %

select * from table1 where host LIKE '%host1%';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.