Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Using multiple values in a SQL "in" statement

by perlvroom (Acolyte)
on May 02, 2013 at 17:51 UTC ( #1031789=note: print w/replies, xml ) Need Help??


in reply to Re: Using multiple values in a SQL "in" statement
in thread Using multiple values in a SQL "in" statement

This worked great. thanks. Can you give me a brief explanation of what's happening at this line?  my $question_mark_string = join(',', ('?') x scalar(@id) );

Replies are listed 'Best First'.
Re^3: Using multiple values in a SQL "in" statement
by jhourcle (Prior) on May 05, 2013 at 13:07 UTC

    It's three operations. The x operator, is either a string or list multiplier. Here, it's being used on an list, as the item is in parens:

       ('?') x scalar(@id)

    scalar(@id) gives the number of items in the array. So we end up with a list of question marks the same size as the @id array.

    The join will flatten a list into a single string, placing the first argument in between each item. So we're placing a comma between each of the question marks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031789]
help
Chatterbox?
[Discipulus]: fore every 2 good old monks that come back, we will accept 1 clinical
[planetscape]: Might be "well, come back!" Discipulus ;-)
[stonecolddevin]: that's a 2.0 k/d ratio, i'll take it
[choroba]: #cbstream still down?
[erix]: yeah, annoying
[choroba]: last ambrus: 1 week ago :-(
[erix]: let's invade Hungary
[planetscape]: darn
[erix]: probably on holiday, the slacker
erix is reduced to use a BROWSER. (remember those?)

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2017-06-22 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (530 votes). Check out past polls.