PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Cross, David" <david dot cross at csfb dot com>
Subject: RE: Using an array in SQL
Date: Jul 31 1998 3:39PM

Why bother iterating across the list twice?

$db->sql(q/select * from table where name in ("/ . join(q/", "/, @array) .
q/")/);

Dave...

--
Dave Cross
Credit Suisse First Boston
+44 (0)171 888 0844

> ----------
> From: 	charmanp@BOLON.UK.ML.COM[SMTP:charmanp@BOLON.UK.ML.COM]
> Sent: 	31 July 1998 17:31
> To: 	SybPerl Discussion List
> Subject: 	Re: Using an array in SQL
> 
> I do it something like this
> 
> map { $_ = "'$_'" } @array ; #put quotes round each item
> $db->sql("select * from table where name in (" . join(',', @array) . ")" )
> ;
>