![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Greetings experts, I have an sql search that requires 'OR' search on two different _fields_ eg. (Sun -- Sybase databases) select f1, f2, ..., fn from tableA, tableB where (tableA.fld_1 = 'abc' OR tableA.fld_2 = 'abc') and tableA.fld_i = tableB.fld_j Without OR, it takes 1 sec to get data from tableA with 500,000 records. With OR, it takes almost 15 - 20 seconds even though both of the search fields are indexed. Is there a way to speed up this search? --------------- Another question... what is the difference between WHERE and HAVING? select ... from ... where ... select ... from ... having ... They're both used for searching, is there any need to use one or the other? Thank you for your help. P.S. I would appreciate if you CC your reply to my email: rlyudmirsky (AT) abac (DOT) com Thanks. -------------------------------------------------------------------- --------- Rostislav "Steve" Lyudmirsky - rlyudmirsky (AT) abac (DOT) com - http://rvl.netfirms.com -------------------------------------------------------------------- --------- "The Universe... is a pretty big place. It's bigger than anything, anyone has ever dreamed of before. So, if it's just us... it seems like an awful waste of space." -- Ellie Arroway (Contact) |
#3
| |||
| |||
|
|
select f1, f2, ..., fn from tableA, tableB where tableA.fld_1 = 'abc' and tableA.fld_i = tableB.fld_j union select f1, f2, ..., fn from tableA, tableB where tableA.fld_2 = 'abc' and tableA.fld_i = tableB.fld_j |
![]() |
| Thread Tools | |
| Display Modes | |
| |