Saturday, 31 August 2013

How to apply regexp in mysqli statement

How to apply regexp in mysqli statement

I'm using pure php and not any CMS such as Wordpress.
I have a product table where there is a cat field for Categories of the
product.
I have a page view that is based on a category. So, for instance I want to
see all mobile phone with brand of Nokia. It means
SELECT * FROM product_table WHERE cat = nokia.
This works just in cases where the product is not multi-category. If the
following product is categorized like this: Nokia, black, new, expensive,
top-rated; then I need to use regexp in my SQL statement. For instance
something like this:
SELECT * FROM product WHERE cat *= Nokia.
My cat field of product table is a string with each cat separated by comma.
Is it correct? What should I do?

No comments:

Post a Comment