| Author |
Topic |
|
simonchia
Starting Member
11 Posts |
Posted - 2004-08-04 : 08:20:05
|
| there has got to be a better way to simplify this query.select * from ins_country as ainner join disti as b on a.disti_ctry_id = b.disti_ctry_id where a.ins_1st_cnt_dt <> '' or a.ins_2nd_cnt_dt <> '' or a.ins_st_cnt_dt <> ''thanks for the help... |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-08-04 : 08:27:54
|
| dunno if this is any better?select * from ins_country as ainner join disti as b on a.disti_ctry_id = b.disti_ctry_id where len(a.ins_1st_cnt_dt + a.ins_2nd_cnt_dt + a.ins_st_cnt_dt) > 0Duane. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-04 : 08:31:55
|
| and what would you like to simplify?you want to get all records that have some text in a.ins_1st_cnt_dt or a.ins_2nd_cnt_dt or a.ins_st_cnt_dt, correct?Go with the flow & have fun! Else fight the flow :) |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-04 : 08:37:12
|
| ditch: wouldn't that actually be slower? because the use of len needs all three fields, and he has an or function which would be true if only one matches. so statisticaly the or is faster. or is my interpretation of sql logic false?Go with the flow & have fun! Else fight the flow :) |
 |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-08-04 : 08:43:56
|
| I have no idea.Mine probably is slower - the best way to find out is if both ways were tested.Duane. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-04 : 08:46:24
|
| well... that up to him :))))Go with the flow & have fun! Else fight the flow :) |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-08-04 : 09:09:00
|
| you COULD say:select * from ins_country as ainner join disti as b on a.disti_ctry_id = b.disti_ctry_id where '' not in (a.ins_1st_cnt_dt, a.ins_2nd_cnt_dt, a.ins_st_cnt_dt )very backwards looking and maybe harder to read, and it will not be any faster than the original solution, but it is a little shorter!- Jeff |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-08-04 : 09:10:18
|
| by the way -- it looks like you could use some normalization. that will certainly make your code shorter and more efficeint. I don't know what those column names mean, but it appears you have repeating columns in your table when you may be better off storing that data in a related table as seperate rows.- Jeff |
 |
|
|
simonchia
Starting Member
11 Posts |
Posted - 2004-08-04 : 22:36:05
|
| thanks for all the reply. either way works fine, just wanted to know the options that i have thats alll..thanks once again. |
 |
|
|
|