MySQL Forums
Forum List  »  Newbie

Re: "SELECT IN SELECT" problem in MySQL
Posted by: Peter Brawley
Date: September 19, 2014 02:55PM

> the result of sql statment "SELECT rsa_lookup_id FROM `rsa_policy_plan_lookup` WHERE rsa_plan_id=1" is "11,12,16"

Then there's something wrong with the database design, the something being a violation of the atomicty rule: columns should not contain lists of values.

IN(list) expects a literal list. To use a dynamic value for the list, concatenate and prepare eg ...

@list = '1,2,3';
@sql = concat( 'select x from a where x in(', @list, ')' );
prepare stmt from @sql;
execute stmt;
drop prepare stmt;

Options: ReplyQuote


Subject
Written By
Posted
Re: "SELECT IN SELECT" problem in MySQL
September 19, 2014 02:55PM


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.