MySQL Forums
Forum List  »  Perl

querying comma seperated values in a db field?
Posted by: Stephen Madison
Date: September 27, 2006 11:39PM

I am trying to pull several field values from a mysql v4.1.12 database using a variable in my WHERE clause that looks for the variable value in a db field that holds several values seperated by commas and even though I have found several methods that claim to be able to handle this process like IN and FIND_IN_SET
I have not been able to get any of the queries to match anything after the first comma in my field that has comma seperated values.

Here is my code:

$dbins_fd_ref = database_quote('category',$fd_ref);

$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 FIND_IN_SET($dbins_fd_ref,product_xcat) ORDER BY RAND($product_name) limit 3

";

my @header = database_call('product','SELECT',$sql_statement);



Thanks for your help on this,

Options: ReplyQuote


Subject
Written By
Posted
querying comma seperated values in a db field?
September 27, 2006 11:39PM


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.