Query Challenge - Help Appreciated 
Author Message
 Query Challenge - Help Appreciated

/*
 I'm struggling w/ my approach to a query.

 I have two entity tables, beer and meta, and a many to many table between
them w/ a value field.
 I parse xml sent via a varchar parameter into a table variable that
contains the meta_id and a value field.
 I need a query that returns all the distinct beer records that have a
record in beer_meta for every
 record in my table variable w/ string containing value fields.  I would
like a solution that works w/ any number
 of records in the table variable and does not have to use iteration.  Is
this possible?  TIA~ PJ
*/

/*   BEGIN SETUP  */
create table beer ( beer_id int )
create table meta ( meta_id int )
create table beer_meta
(
 beer_id int ,
 meta_id int ,
 value varchar(50)
)




begin



end

insert beer_meta ( beer_id, meta_id, value )
values ( 1, 1, 'Pilsner')
insert beer_meta ( beer_id, meta_id, value )
values ( 1, 2, 'USA')
insert beer_meta ( beer_id, meta_id, value )
values ( 1, 3, 'great tasting beer')
insert beer_meta ( beer_id, meta_id, value )
values ( 2, 1, 'Lager')
insert beer_meta ( beer_id, meta_id, value )
values ( 2, 3, 'mellow blend')
insert beer_meta ( beer_id, meta_id, value )
values ( 3, 1, 'Stout')
insert beer_meta ( beer_id, meta_id, value )
values ( 3, 2, 'USA')
insert beer_meta ( beer_id, meta_id, value )
values ( 3, 3, 'mixed blend beer')
/*   END SETUP  */

go

(
 meta_id int ,
 value varchar(50)
)


values ( 2, '%USA%' )

values ( 3, '%beer%' )

/*
*** NEEDED QUERY ***

======== DESIRED RESULTS ========
beer_id
1
3

beer records 1 and 3 both have beer_meta records for meta_id 2 contains
'USA'
    and meta_id 3 contains 'beer'
*/



values ( 1, '%Stout%')

values ( 3, '%blend%')

/*
*** NEEDED QUERY ***

======== DESIRED RESULTS ========
beer_id
3

only beer record 3 has beer_meta records for meta_id 1contains 'Stout'
    and meta_id 3 contains 'blend'
*/

drop table beer
drop table meta
drop table beer_meta



Sun, 22 Jan 2006 20:21:12 GMT
 Query Challenge - Help Appreciated

The same query can be used throughout...

select beer_id

s.value
group by beer_id

--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net


Quote:
> /*
>  I'm struggling w/ my approach to a query.

>  I have two entity tables, beer and meta, and a many to many table between
> them w/ a value field.
>  I parse xml sent via a varchar parameter into a table variable that
> contains the meta_id and a value field.
>  I need a query that returns all the distinct beer records that have a
> record in beer_meta for every
>  record in my table variable w/ string containing value fields.  I would
> like a solution that works w/ any number
>  of records in the table variable and does not have to use iteration.  Is
> this possible?  TIA~ PJ
> */

> /*   BEGIN SETUP  */
> create table beer ( beer_id int )
> create table meta ( meta_id int )
> create table beer_meta
> (
>  beer_id int ,
>  meta_id int ,
>  value varchar(50)
> )




> begin



> end

> insert beer_meta ( beer_id, meta_id, value )
> values ( 1, 1, 'Pilsner')
> insert beer_meta ( beer_id, meta_id, value )
> values ( 1, 2, 'USA')
> insert beer_meta ( beer_id, meta_id, value )
> values ( 1, 3, 'great tasting beer')
> insert beer_meta ( beer_id, meta_id, value )
> values ( 2, 1, 'Lager')
> insert beer_meta ( beer_id, meta_id, value )
> values ( 2, 3, 'mellow blend')
> insert beer_meta ( beer_id, meta_id, value )
> values ( 3, 1, 'Stout')
> insert beer_meta ( beer_id, meta_id, value )
> values ( 3, 2, 'USA')
> insert beer_meta ( beer_id, meta_id, value )
> values ( 3, 3, 'mixed blend beer')
> /*   END SETUP  */

> go

> (
>  meta_id int ,
>  value varchar(50)
> )


> values ( 2, '%USA%' )

> values ( 3, '%beer%' )

> /*
> *** NEEDED QUERY ***

> ======== DESIRED RESULTS ========
> beer_id
> 1
> 3

> beer records 1 and 3 both have beer_meta records for meta_id 2 contains
> 'USA'
>     and meta_id 3 contains 'beer'
> */



> values ( 1, '%Stout%')

> values ( 3, '%blend%')

> /*
> *** NEEDED QUERY ***

> ======== DESIRED RESULTS ========
> beer_id
> 3

> only beer record 3 has beer_meta records for meta_id 1contains 'Stout'
>     and meta_id 3 contains 'blend'
> */

> drop table beer
> drop table meta
> drop table beer_meta



Sun, 22 Jan 2006 20:42:29 GMT
 Query Challenge - Help Appreciated
Do:

SELECT b1.beer_id
  FROM beer_meta b1

    ON s1.meta_id = b1.meta_id
   AND PATINDEX(s1.value, b1.value) > 0   -- or use LIKE
 GROUP BY b1.beer_id

--
- Anith
( Please reply to newsgroups only )



Sun, 22 Jan 2006 20:54:02 GMT
 Query Challenge - Help Appreciated
ah, nice...that's just what i came up w/...
?:  does it make a difference whether or not i predetermine the # of records



...


row scan?

thx! PJ


Quote:
> The same query can be used throughout...

> select beer_id

> s.value
> group by beer_id

> --
> -oj
> RAC v2.2 & QALite!
> http://www.rac4sql.net



> > /*
> >  I'm struggling w/ my approach to a query.

> >  I have two entity tables, beer and meta, and a many to many table
between
> > them w/ a value field.
> >  I parse xml sent via a varchar parameter into a table variable that
> > contains the meta_id and a value field.
> >  I need a query that returns all the distinct beer records that have a
> > record in beer_meta for every
> >  record in my table variable w/ string containing value fields.  I would
> > like a solution that works w/ any number
> >  of records in the table variable and does not have to use iteration.
Is
> > this possible?  TIA~ PJ
> > */

> > /*   BEGIN SETUP  */
> > create table beer ( beer_id int )
> > create table meta ( meta_id int )
> > create table beer_meta
> > (
> >  beer_id int ,
> >  meta_id int ,
> >  value varchar(50)
> > )




> > begin



> > end

> > insert beer_meta ( beer_id, meta_id, value )
> > values ( 1, 1, 'Pilsner')
> > insert beer_meta ( beer_id, meta_id, value )
> > values ( 1, 2, 'USA')
> > insert beer_meta ( beer_id, meta_id, value )
> > values ( 1, 3, 'great tasting beer')
> > insert beer_meta ( beer_id, meta_id, value )
> > values ( 2, 1, 'Lager')
> > insert beer_meta ( beer_id, meta_id, value )
> > values ( 2, 3, 'mellow blend')
> > insert beer_meta ( beer_id, meta_id, value )
> > values ( 3, 1, 'Stout')
> > insert beer_meta ( beer_id, meta_id, value )
> > values ( 3, 2, 'USA')
> > insert beer_meta ( beer_id, meta_id, value )
> > values ( 3, 3, 'mixed blend beer')
> > /*   END SETUP  */

> > go

> > (
> >  meta_id int ,
> >  value varchar(50)
> > )


> > values ( 2, '%USA%' )

> > values ( 3, '%beer%' )

> > /*
> > *** NEEDED QUERY ***

> > ======== DESIRED RESULTS ========
> > beer_id
> > 1
> > 3

> > beer records 1 and 3 both have beer_meta records for meta_id 2 contains
> > 'USA'
> >     and meta_id 3 contains 'beer'
> > */



> > values ( 1, '%Stout%')

> > values ( 3, '%blend%')

> > /*
> > *** NEEDED QUERY ***

> > ======== DESIRED RESULTS ========
> > beer_id
> > 3

> > only beer record 3 has beer_meta records for meta_id 1contains 'Stout'
> >     and meta_id 3 contains 'blend'
> > */

> > drop table beer
> > drop table meta
> > drop table beer_meta



Sun, 22 Jan 2006 21:24:58 GMT
 Query Challenge - Help Appreciated
Are OJ and pj the same?  :)

Quote:
> ah, nice...that's just what i came up w/...
> ?:  does it make a difference whether or not i predetermine the # of
records



> ...


> row scan?

> thx! PJ



> > The same query can be used throughout...

> > select beer_id

like
> > s.value
> > group by beer_id

> > --
> > -oj
> > RAC v2.2 & QALite!
> > http://www.rac4sql.net



> > > /*
> > >  I'm struggling w/ my approach to a query.

> > >  I have two entity tables, beer and meta, and a many to many table
> between
> > > them w/ a value field.
> > >  I parse xml sent via a varchar parameter into a table variable that
> > > contains the meta_id and a value field.
> > >  I need a query that returns all the distinct beer records that have a
> > > record in beer_meta for every
> > >  record in my table variable w/ string containing value fields.  I
would
> > > like a solution that works w/ any number
> > >  of records in the table variable and does not have to use iteration.
> Is
> > > this possible?  TIA~ PJ
> > > */

> > > /*   BEGIN SETUP  */
> > > create table beer ( beer_id int )
> > > create table meta ( meta_id int )
> > > create table beer_meta
> > > (
> > >  beer_id int ,
> > >  meta_id int ,
> > >  value varchar(50)
> > > )




> > > begin



> > > end

> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 1, 1, 'Pilsner')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 1, 2, 'USA')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 1, 3, 'great tasting beer')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 2, 1, 'Lager')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 2, 3, 'mellow blend')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 3, 1, 'Stout')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 3, 2, 'USA')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 3, 3, 'mixed blend beer')
> > > /*   END SETUP  */

> > > go

> > > (
> > >  meta_id int ,
> > >  value varchar(50)
> > > )


> > > values ( 2, '%USA%' )

> > > values ( 3, '%beer%' )

> > > /*
> > > *** NEEDED QUERY ***

> > > ======== DESIRED RESULTS ========
> > > beer_id
> > > 1
> > > 3

> > > beer records 1 and 3 both have beer_meta records for meta_id 2
contains
> > > 'USA'
> > >     and meta_id 3 contains 'beer'
> > > */



> > > values ( 1, '%Stout%')

> > > values ( 3, '%blend%')

> > > /*
> > > *** NEEDED QUERY ***

> > > ======== DESIRED RESULTS ========
> > > beer_id
> > > 3

> > > only beer record 3 has beer_meta records for meta_id 1contains 'Stout'
> > >     and meta_id 3 contains 'blend'
> > > */

> > > drop table beer
> > > drop table meta
> > > drop table beer_meta



Sun, 22 Jan 2006 22:24:05 GMT
 Query Challenge - Help Appreciated
hehehheh...what ya think...

--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net


Quote:
> Are OJ and pj the same?  :)


> > ah, nice...that's just what i came up w/...
> > ?:  does it make a difference whether or not i predetermine the # of
> records



> > ...


every
> > row scan?

> > thx! PJ



> > > The same query can be used throughout...

> > > select beer_id

> like
> > > s.value
> > > group by beer_id

> > > --
> > > -oj
> > > RAC v2.2 & QALite!
> > > http://www.rac4sql.net



> > > > /*
> > > >  I'm struggling w/ my approach to a query.

> > > >  I have two entity tables, beer and meta, and a many to many table
> > between
> > > > them w/ a value field.
> > > >  I parse xml sent via a varchar parameter into a table variable that
> > > > contains the meta_id and a value field.
> > > >  I need a query that returns all the distinct beer records that have
a
> > > > record in beer_meta for every
> > > >  record in my table variable w/ string containing value fields.  I
> would
> > > > like a solution that works w/ any number
> > > >  of records in the table variable and does not have to use
iteration.
> > Is
> > > > this possible?  TIA~ PJ
> > > > */

> > > > /*   BEGIN SETUP  */
> > > > create table beer ( beer_id int )
> > > > create table meta ( meta_id int )
> > > > create table beer_meta
> > > > (
> > > >  beer_id int ,
> > > >  meta_id int ,
> > > >  value varchar(50)
> > > > )




> > > > begin



> > > > end

> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 1, 1, 'Pilsner')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 1, 2, 'USA')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 1, 3, 'great tasting beer')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 2, 1, 'Lager')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 2, 3, 'mellow blend')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 3, 1, 'Stout')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 3, 2, 'USA')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 3, 3, 'mixed blend beer')
> > > > /*   END SETUP  */

> > > > go

> > > > (
> > > >  meta_id int ,
> > > >  value varchar(50)
> > > > )


> > > > values ( 2, '%USA%' )

> > > > values ( 3, '%beer%' )

> > > > /*
> > > > *** NEEDED QUERY ***

> > > > ======== DESIRED RESULTS ========
> > > > beer_id
> > > > 1
> > > > 3

> > > > beer records 1 and 3 both have beer_meta records for meta_id 2
> contains
> > > > 'USA'
> > > >     and meta_id 3 contains 'beer'
> > > > */



> > > > values ( 1, '%Stout%')

> > > > values ( 3, '%blend%')

> > > > /*
> > > > *** NEEDED QUERY ***

> > > > ======== DESIRED RESULTS ========
> > > > beer_id
> > > > 3

> > > > only beer record 3 has beer_meta records for meta_id 1contains
'Stout'
> > > >     and meta_id 3 contains 'blend'
> > > > */

> > > > drop table beer
> > > > drop table meta
> > > > drop table beer_meta



Sun, 22 Jan 2006 22:24:37 GMT
 Query Challenge - Help Appreciated
having clause is done on the resultset prior to returning it to the caller,
hence, count(*) is done only once.

--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net


Quote:
> ah, nice...that's just what i came up w/...
> ?:  does it make a difference whether or not i predetermine the # of
records



> ...


> row scan?

> thx! PJ



> > The same query can be used throughout...

> > select beer_id

like
> > s.value
> > group by beer_id

> > --
> > -oj
> > RAC v2.2 & QALite!
> > http://www.rac4sql.net



> > > /*
> > >  I'm struggling w/ my approach to a query.

> > >  I have two entity tables, beer and meta, and a many to many table
> between
> > > them w/ a value field.
> > >  I parse xml sent via a varchar parameter into a table variable that
> > > contains the meta_id and a value field.
> > >  I need a query that returns all the distinct beer records that have a
> > > record in beer_meta for every
> > >  record in my table variable w/ string containing value fields.  I
would
> > > like a solution that works w/ any number
> > >  of records in the table variable and does not have to use iteration.
> Is
> > > this possible?  TIA~ PJ
> > > */

> > > /*   BEGIN SETUP  */
> > > create table beer ( beer_id int )
> > > create table meta ( meta_id int )
> > > create table beer_meta
> > > (
> > >  beer_id int ,
> > >  meta_id int ,
> > >  value varchar(50)
> > > )




> > > begin



> > > end

> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 1, 1, 'Pilsner')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 1, 2, 'USA')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 1, 3, 'great tasting beer')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 2, 1, 'Lager')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 2, 3, 'mellow blend')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 3, 1, 'Stout')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 3, 2, 'USA')
> > > insert beer_meta ( beer_id, meta_id, value )
> > > values ( 3, 3, 'mixed blend beer')
> > > /*   END SETUP  */

> > > go

> > > (
> > >  meta_id int ,
> > >  value varchar(50)
> > > )


> > > values ( 2, '%USA%' )

> > > values ( 3, '%beer%' )

> > > /*
> > > *** NEEDED QUERY ***

> > > ======== DESIRED RESULTS ========
> > > beer_id
> > > 1
> > > 3

> > > beer records 1 and 3 both have beer_meta records for meta_id 2
contains
> > > 'USA'
> > >     and meta_id 3 contains 'beer'
> > > */



> > > values ( 1, '%Stout%')

> > > values ( 3, '%blend%')

> > > /*
> > > *** NEEDED QUERY ***

> > > ======== DESIRED RESULTS ========
> > > beer_id
> > > 3

> > > only beer record 3 has beer_meta records for meta_id 1contains 'Stout'
> > >     and meta_id 3 contains 'blend'
> > > */

> > > drop table beer
> > > drop table meta
> > > drop table beer_meta



Sun, 22 Jan 2006 22:24:12 GMT
 Query Challenge - Help Appreciated
ah, good to know...a where clause for aggregates so to speak...thx again!


Quote:
> having clause is done on the resultset prior to returning it to the
caller,
> hence, count(*) is done only once.

> --
> -oj
> RAC v2.2 & QALite!
> http://www.rac4sql.net



> > ah, nice...that's just what i came up w/...
> > ?:  does it make a difference whether or not i predetermine the # of
> records



> > ...


every
> > row scan?

> > thx! PJ



> > > The same query can be used throughout...

> > > select beer_id

> like
> > > s.value
> > > group by beer_id

> > > --
> > > -oj
> > > RAC v2.2 & QALite!
> > > http://www.rac4sql.net



> > > > /*
> > > >  I'm struggling w/ my approach to a query.

> > > >  I have two entity tables, beer and meta, and a many to many table
> > between
> > > > them w/ a value field.
> > > >  I parse xml sent via a varchar parameter into a table variable that
> > > > contains the meta_id and a value field.
> > > >  I need a query that returns all the distinct beer records that have
a
> > > > record in beer_meta for every
> > > >  record in my table variable w/ string containing value fields.  I
> would
> > > > like a solution that works w/ any number
> > > >  of records in the table variable and does not have to use
iteration.
> > Is
> > > > this possible?  TIA~ PJ
> > > > */

> > > > /*   BEGIN SETUP  */
> > > > create table beer ( beer_id int )
> > > > create table meta ( meta_id int )
> > > > create table beer_meta
> > > > (
> > > >  beer_id int ,
> > > >  meta_id int ,
> > > >  value varchar(50)
> > > > )




> > > > begin



> > > > end

> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 1, 1, 'Pilsner')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 1, 2, 'USA')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 1, 3, 'great tasting beer')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 2, 1, 'Lager')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 2, 3, 'mellow blend')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 3, 1, 'Stout')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 3, 2, 'USA')
> > > > insert beer_meta ( beer_id, meta_id, value )
> > > > values ( 3, 3, 'mixed blend beer')
> > > > /*   END SETUP  */

> > > > go

> > > > (
> > > >  meta_id int ,
> > > >  value varchar(50)
> > > > )


> > > > values ( 2, '%USA%' )

> > > > values ( 3, '%beer%' )

> > > > /*
> > > > *** NEEDED QUERY ***

> > > > ======== DESIRED RESULTS ========
> > > > beer_id
> > > > 1
> > > > 3

> > > > beer records 1 and 3 both have beer_meta records for meta_id 2
> contains
> > > > 'USA'
> > > >     and meta_id 3 contains 'beer'
> > > > */



> > > > values ( 1, '%Stout%')

> > > > values ( 3, '%blend%')

> > > > /*
> > > > *** NEEDED QUERY ***

> > > > ======== DESIRED RESULTS ========
> > > > beer_id
> > > > 3

> > > > only beer record 3 has beer_meta records for meta_id 1contains
'Stout'
> > > >     and meta_id 3 contains 'blend'
> > > > */

> > > > drop table beer
> > > > drop table meta
> > > > drop table beer_meta



Sun, 22 Jan 2006 23:44:43 GMT
 Query Challenge - Help Appreciated
yup...ya welcome.

--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net


Quote:
> ah, good to know...a where clause for aggregates so to speak...thx again!



> > having clause is done on the resultset prior to returning it to the
> caller,
> > hence, count(*) is done only once.

> > --
> > -oj
> > RAC v2.2 & QALite!
> > http://www.rac4sql.net



> > > ah, nice...that's just what i came up w/...
> > > ?:  does it make a difference whether or not i predetermine the # of
> > records



> > > ...


> every
> > > row scan?

> > > thx! PJ



> > > > The same query can be used throughout...

> > > > select beer_id

bm.value
> > like
> > > > s.value
> > > > group by beer_id

> > > > --
> > > > -oj
> > > > RAC v2.2 & QALite!
> > > > http://www.rac4sql.net



> > > > > /*
> > > > >  I'm struggling w/ my approach to a query.

> > > > >  I have two entity tables, beer and meta, and a many to many table
> > > between
> > > > > them w/ a value field.
> > > > >  I parse xml sent via a varchar parameter into a table variable
that
> > > > > contains the meta_id and a value field.
> > > > >  I need a query that returns all the distinct beer records that
have
> a
> > > > > record in beer_meta for every
> > > > >  record in my table variable w/ string containing value fields.  I
> > would
> > > > > like a solution that works w/ any number
> > > > >  of records in the table variable and does not have to use
> iteration.
> > > Is
> > > > > this possible?  TIA~ PJ
> > > > > */

> > > > > /*   BEGIN SETUP  */
> > > > > create table beer ( beer_id int )
> > > > > create table meta ( meta_id int )
> > > > > create table beer_meta
> > > > > (
> > > > >  beer_id int ,
> > > > >  meta_id int ,
> > > > >  value varchar(50)
> > > > > )




> > > > > begin



> > > > > end

> > > > > insert beer_meta ( beer_id, meta_id, value )
> > > > > values ( 1, 1, 'Pilsner')
> > > > > insert beer_meta ( beer_id, meta_id, value )
> > > > > values ( 1, 2, 'USA')
> > > > > insert beer_meta ( beer_id, meta_id, value )
> > > > > values ( 1, 3, 'great tasting beer')
> > > > > insert beer_meta ( beer_id, meta_id, value )
> > > > > values ( 2, 1, 'Lager')
> > > > > insert beer_meta ( beer_id, meta_id, value )
> > > > > values ( 2, 3, 'mellow blend')
> > > > > insert beer_meta ( beer_id, meta_id, value )
> > > > > values ( 3, 1, 'Stout')
> > > > > insert beer_meta ( beer_id, meta_id, value )
> > > > > values ( 3, 2, 'USA')
> > > > > insert beer_meta ( beer_id, meta_id, value )
> > > > > values ( 3, 3, 'mixed blend beer')
> > > > > /*   END SETUP  */

> > > > > go

> > > > > (
> > > > >  meta_id int ,
> > > > >  value varchar(50)
> > > > > )


> > > > > values ( 2, '%USA%' )

> > > > > values ( 3, '%beer%' )

> > > > > /*
> > > > > *** NEEDED QUERY ***

> > > > > ======== DESIRED RESULTS ========
> > > > > beer_id
> > > > > 1
> > > > > 3

> > > > > beer records 1 and 3 both have beer_meta records for meta_id 2
> > contains
> > > > > 'USA'
> > > > >     and meta_id 3 contains 'beer'
> > > > > */



> > > > > values ( 1, '%Stout%')

> > > > > values ( 3, '%blend%')

> > > > > /*
> > > > > *** NEEDED QUERY ***

> > > > > ======== DESIRED RESULTS ========
> > > > > beer_id
> > > > > 3

> > > > > only beer record 3 has beer_meta records for meta_id 1contains
> 'Stout'
> > > > >     and meta_id 3 contains 'blend'
> > > > > */

> > > > > drop table beer
> > > > > drop table meta
> > > > > drop table beer_meta



Sun, 22 Jan 2006 23:54:10 GMT
 
 [ 9 post ] 

 Relevant Pages 

1. query help appreciated. max()/joins/subquery

2. query help appreciated

3. Simple Contains Query Question (any help appreciated)

4. slow query -- help much appreciated

5. query help appreciated

6. Complex query, some help would be appreciated

7. Help for query interface design would be highly appreciated

8. Ado Help Please Help any help is appreciated

9. Need expert help... a challenging query

10. help, a SQL query challenge

11. Need expert help... a challenging query

12. Need expert help... a challenging query


 
Powered by phpBB® Forum Software