Subject | Re: [firebird-support] IN alternative |
---|---|
Author | Gary Benade |
Post date | 2005-03-12T11:08:06Z |
Hi Helen
Thanks for your time and valuable insights :) Very very very much
appreciated.
query was waaaaaay off base. The second example you gave works very well,
with sub second query times. The only problem is that it only works for
single word matches.
[ORDERITEMS]
LINK ITEM
-----------------
1 CHEESE PITA
2 CHICKEN PITA
[MENU_WORD_SEARCH]
LINK WORD
------------------
100 CHEESE
101 PITA
102 CHICKEN
[ORDERITEMS_WORD_MATCH]
ORDERITEMLINK WORDSEARCHLINK
--------------------
1 100
1 101
2 101
2 102
join orderitems_word_match ows
on ows.orderitemlink = oi.link
and exists (
select 1 from menu_word_search mws1
where mws1.link = ows.wordlink
and mws1.word = 'PITA' )
join orderitems_word_match ows
on ows.orderitemlink = oi.link
and exists (
select 1 from menu_word_search mws1
where mws1.link = ows.wordlink
and mws1.word = 'PITA' )
and exists (
select 1 from menu_word_search mws1
where mws1.link = ows.wordlink
and mws1.word = 'CHEESE' )
Any further help or suggestions will be greatly appreciated,
TIA
Gary
Thanks for your time and valuable insights :) Very very very much
appreciated.
> select oi.* from orderitems oiThis is pretty much the way I have structured the data, but I think my first
> join orderitems_word_match ows
> on ows.orderitem_id = oi.orderitem_id
> and exists (
> select 1 from menu_word_search mws1
> where mws1.m_w_s = ows.m_w_s
> and mws1.word = 'PITA' )
> and exists (
> select 1 from menu_word_search mws2
> where mws2.m_w_s = ows.m_w_s
> and mws2.word = 'CHEESE' )
> /* keep going if you like */
> and exists (
> select 1 from menu_word_search mws3
> where mws3.m_w_s = ows.m_w_s
> and mws3.word = 'HUMMUS')
>
> Then you can recycle the keywords for use with many tables, by creating
> just one intersection table for each table that has a searchable text
> field
> in it.
query was waaaaaay off base. The second example you gave works very well,
with sub second query times. The only problem is that it only works for
single word matches.
[ORDERITEMS]
LINK ITEM
-----------------
1 CHEESE PITA
2 CHICKEN PITA
[MENU_WORD_SEARCH]
LINK WORD
------------------
100 CHEESE
101 PITA
102 CHICKEN
[ORDERITEMS_WORD_MATCH]
ORDERITEMLINK WORDSEARCHLINK
--------------------
1 100
1 101
2 101
2 102
>> This worksselect oi.* from orderitems oi
join orderitems_word_match ows
on ows.orderitemlink = oi.link
and exists (
select 1 from menu_word_search mws1
where mws1.link = ows.wordlink
and mws1.word = 'PITA' )
>> This doesntselect oi.* from orderitems oi
join orderitems_word_match ows
on ows.orderitemlink = oi.link
and exists (
select 1 from menu_word_search mws1
where mws1.link = ows.wordlink
and mws1.word = 'PITA' )
and exists (
select 1 from menu_word_search mws1
where mws1.link = ows.wordlink
and mws1.word = 'CHEESE' )
Any further help or suggestions will be greatly appreciated,
TIA
Gary