|
|
sybperl-l Archive
Up Prev Next
From: "Brent B dot Powers Swaps Programmer x2293" <powers at swaps-comm dot ml dot com>
Subject: Framing search sql's
Date: Feb 2 1996 2:18AM
Shankar Kris writes:
> Hello,
>
> I maintain a list that has *data* on which to search for.
> @list = qw( 1 2 3 4 5);
>
> I frame the 'sql' like this:
>
> $"=',';
> $sql = "select col1,col2 from table_name where col1 in (@list)";
>
> This works fine when the search list involves integer data types.
>
> While searching for char data types. since each element has to enclosed
> in quotes. I am unable to come up with a simple elegant way to frame the
> search 'sql'. Is there a good way to do this. else I might just loop
> thru eeach element and frame the sql.
>
> Any suggestions.
>
$sql = "select col1, col2 from table_name where col1 in ('" . join("', '",@list) . "')";
Brent B. Powers Merrill Lynch powers@swaps.ml.com
|