Perl & MySQL (SELECT)
A while ago I asked for help on the following: > I would like to be able to select records from the a table where record_id > and $record_id from my @record_ids matches. I know I could go through a loop > and send a SELECT query for each element in the array but is there a better > way? How can I accomplish the same but only sending one query? One of the responses was the following solution: @record_ids = param ('record_ids'); my $sql = qq{SELECT ad_id, text, life FROM $table WHERE ad_id in(' . join(',',@record_ids) . ')}; then execute the $sql only once However that doesn't find any records, any obvious mistakes in my sql statement that you can notice? thanks a lot, M > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl & MySQL (SELECT)
On Fri, 22 Nov 2002 11:56:44 -0600, "Mariusz" <[EMAIL PROTECTED]> wrote: > A while ago I asked for help on the following: > > > I would like to be able to select records from the a table where record_id > > and $record_id from my @record_ids matches. I know I could go through a > loop > > and send a SELECT query for each element in the array but is there a > better > > way? How can I accomplish the same but only sending one query? > > One of the responses was the following solution: > > @record_ids = param ('record_ids'); > > my $sql = qq{SELECT ad_id, text, life FROM $table WHERE ad_id in(' . > join(',',@record_ids) . ')}; > > then execute the $sql only once > > > However that doesn't find any records, any obvious mistakes in my sql > statement that you can notice? > > > thanks a lot, > M > In your original post you said "where record_id" but in your select statement you have "ad_id in" should this be "record_id in"?? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]