[SOLVED] Query with parameter and LIKE operator

No replies
z3dom
Offline
Last seen: 50 weeks 2 days ago
Title:
Joined: 12 Jun 2015
Posts: 2
Hello. If I use Query with parameter, e.g. SELECT id FROM table1 WHERE column1 = :PARAMETR then everything work OK. But I need to use LIKE operator with some pattern. For example I want to find all id where column1 include “777”:

id column1
1 34577742
2 52345777
3 34235
4 774
5 777777

So the result should be 1,2 and 5.

It is good when I use “SELECT id FROM table1 WHERE column1 LIKE777’” but when I am trying to use parameter query – “SELECT id FROM table1 WHERE column1 LIKE :PARAMETR’ it doesn’t work. I can’t input in the parametr 777.

I hope my question is clear…
Thank you for all ideas.

SOLUTION:


SELECT `ID` FROM `work`.`phones` AS `phones` WHERE `phone` LIKE CONCAT( '%', :PHONE, '%' )