Thanks, that works (I'll have to read a bit to learn why) except for one thing I didn't mention. (Everybody Lies :) How ugly is this?
$sql = "INSERT into $table2"; # dynamic name with $user_id as root $sql .= sprintf <<'EOF', join(',', @array);
I see. I suppose this produced quite a few grins. Happy to oblige. :)
Thanks again Eamon, --Jon
(col2, col3, ...) SELECT col2, col3, ... FROM table1 WHERE col1 IN (%s) EOF
You could simplify it like this:
$sql = sprintf <<'EOF', $table2, join(',', @array); INSERT INTO %s (col2, col3, ...) SELECT col2, col3, ... FROM table1 WHERE col1 IN (%s) EOF
SOme explanation of the details:
- join(',', @array)
join concats a list to a string, joined by some character. See "perldoc -f join".
- sprintf
sprintf behaves like its C counterpart and allows interpolation of numbers and strings. See "perldoc -f sprintf".
- <<'EOF'
That's a "here document". We put it in single quotes so perl-ish stuff like '$' and '@' are not interpolated. See http://www.perlmeme.org/howtos/interpolation.html
____________________________________________________________ Eamon Daly
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
