Hi,
I have a few thousand col1, col2 distinct values. Col1 -> some primary key and Col 2 -> date.
For a third col 3, i have to query a large table, which gives me only few hundred results in most cases.
now my concern is how can write my where condition or use unions so that the number of times i am querying my DB decreases. my program is slow due to this.
Currently I was doing of doing something like below in my perl program using DBI.
select COL3 from Table where (COL1='v1' and COL2='Sep 25 2007 12:00AM' ) or (COL1='b3' and COL2='Sep 28 2007 12:00AM')
or (COL1='c1' and COL2='Sep 11 2007 12:00AM') and COL3='ABCD'
union
select COL3 from Table where (COL1='v2' and COL2='Sep 28 2007 12:00AM') or (COL1='b2' and COL2='Oct 1 2007 12:00AM')
or (COL1='c2' and COL2='Sep 28 2007 12:00AM') and COL3='ABCD'
union
select COL3 from Table where (COL1='v3' and COL2='Oct 1 2007 12:00AM') or (COL1='b1' and COL2='Sep 28 2007 12:00AM')
or (COL1='c3' and COL2='Sep 24 2007 12:00AM') and COL3='ABCD'