Simple PHP query question: LIKE

Posted by pg on Stack Overflow See other posts from Stack Overflow or by pg
Published on 2010-05-14T18:12:07Z Indexed on 2010/05/14 18:14 UTC
Read the original article Hit count: 148

Filed under:
|
|

When I replace

$ordering = "apples, bananas, cranberries, grapes";

with

$ordering = "apples, bananas, grapes";

I no longer want cranberries to be returned by my query, which I've written out like this:

$query = "SELECT * from dbname where FruitName LIKE '$ordering'";

Of Course this doesn't work, because I used LIKE wrong. I've read through various manuals that describe how to use LIKE and it doesn't quite make sense to me.

If I change the end of the db to "LIKE "apples"" that works for limiting it to just apples. Do I have to explode the ordering on the ", " or is there a way to do this in the query?

© Stack Overflow or respective owner

Related posts about mysql-query

Related posts about like