SELECT and DECODE using LIKE??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Oefinger

    #1

    SELECT and DECODE using LIKE??

    Hello gurus,

    I'm trying to do a search through an encrypted database (to which I
    have the key). I want to use the LIKE operator in MySQL rather than
    dumping out all entries and sorting in Perl, since MySQL will be much
    faster at digging up the right information.

    I'm not having any luck with the following (I'm using DBI in Perl, so
    $ is Perl variable stuff):

    SELECT(DECODE(" Last_Name",$KEY ) from $TABLE where
    DECODE(Last_Nam e,$KEY) like "A%").

    More exactly, my Perl DBI code looks like:

    my $ps="SELECT DECODE(\"Last_N ame\",\"$ACCOUN T_KEY\"),
    DECODE(\"First_ Name\",\"$ACCOU NT_KEY\"),
    DECODE(\"SSN\", \"$ACCOUNT_KEY\ ") from $tablename WHERE
    DECODE(Last_Nam e,\"$ACCOUNT_KE Y\") LIKE \"$letter\") ";

    I've also tried quotes around the latter Last_Name, but that doesn't
    work either. The idea is that I want SQL to decrypt the column entry
    before performing the LIKE comparison.

    Thanks,
    Matt
    oefinger@mit.ed u
Working...