user2243125
user2243125

Reputation: 5

Having trouble using LIKE %...%

So I'm trying to use the LIKE %...% what I have so far is this

SELECT * FROM stores WHERE 'name' LIKE '%$searchTerm%' AND price > 0

Unfortunately this returns the entire table instead of the specific term that is being searched. I also checked the value of the $searchTerm variable and it's working as intended.

Upvotes: 0

Views: 54

Answers (1)

uvais
uvais

Reputation: 416

do not provide single quotes around your column name : if name is your column_name then try this:

 SELECT * FROM stores WHERE name LIKE '%".$searchTerm."%' AND price > 0

Upvotes: 4

Related Questions