MySQL Forums
Forum List  »  Perl

Re: querying comma seperated values in a db field?
Posted by: Stephen Madison
Date: September 28, 2006 09:49AM

Here is my sql statement:

$sql_statement ="

SELECT product.product_id, product.product_name, product.product_imgsm, product.product_xcat, category.category_header_name, category.category_imgsm FROM product JOIN category ON product.product_xcat=category.category_id WHERE product_xcat IN($dbins_fd_ref) ORDER BY RAND($product_name) limit 3

";


All that I need to do is make the WHERE clause search for a string literal that is respresented by the $dbins_fd_ref variable in a comma separated list that resides in the product_xcat column of the product table and return the select statement results when the string literal is found. I do not need for ALL of the comma seperated values to match, I am looking for the existance of the $dbins_fd_ref literal in one or more of the comma separated values of the product_xcat column.

I have tried IN and FIND_IN_SET with no luck.

Thank you for helping me with this.

Options: ReplyQuote


Subject
Written By
Posted
Re: querying comma seperated values in a db field?
September 28, 2006 09:49AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.