|
|
sybperl-l Archive
Up Prev Next
From: "Lee Wenzler" <leew at roanoketimes dot com>
Subject: Sql or Sybperl advice needed
Date: Jun 18 2002 2:27PM
Sybperl hash advice needed:
I'm using Sybase::Simple and need a method of selecting a row from a
table used to translate from one system to another where there are
matches of one more columns, but I want the row that has the most
matches (I'm hoping to use some type of hash table for this). All of
the source columns can have null (don't care) values too. For example,
with a table that has these columns:
a int
b int
c int
d int
e int
x char(4)
In this example a = 1, b = 2, c = 4, d = 5, e = 10 and @my_range = 7
select x from test_table where a = 1 and b = 2 and c = 3 and @my_range
between d and e
That would get x in this case, but what if a and b were null (don't care
values), or the d and e columns were null (also don't care)?
The clunky way I get it to work is start with the most selective and
work my way down until I get a hit or give up.
Would a hash table of some sort work for this?
Thanks.
Lee Wenzler
Publishing System Mgr.
The Roanoke Times
|