Re: Maybe easy, maybe hard SELECT puzzle :)

2003-11-12 Thread Michael Stassen
Jonathan Terhorst wrote: I can't figure out if this is actually challenging or if it's a stupid question. Table1 is a normal old relation that describes a bunch of objects: Table1 (id INT PRIMARY KEY NOT NULL, Name varchar(255), Size int) etc. Associated with each Table1 record is a variable-lengt

Re: Maybe easy, maybe hard SELECT puzzle :)

2003-11-12 Thread Shane Allen
At 09:24 PM 11/10/2003, Leo wrote: notice the _and_ ? *grin* good point. I guess my reply (which I found out later was unnecessary since the question had already been answered) would have been better stated had I just pointed out the distinct keyword rather than constructing a sample query. :)

Re: Maybe easy, maybe hard SELECT puzzle :)

2003-11-12 Thread Jonathan Terhorst
AIL PROTECTED]> Sent: Monday, November 10, 2003 8:26 PM Subject: Re: Maybe easy, maybe hard SELECT puzzle :) > At 07:45 PM 11/7/2003, Jonathan Terhorst wrote: > > > >One way I have found to implement this is > >SELECT Table1.id from Table1 JOIN Features USING(id) WHERE

Re: Maybe easy, maybe hard SELECT puzzle :)

2003-11-10 Thread Leo
>SELECT DISTINCT f.id FROM Table1 AS t, Features AS f >WHERE f.id = t.id AND f.FeatureCode IN ('A01', 'B02'); >HTH what if i have a record that have 'A01' in the features, but not 'B02' wouldnt it still be displayed in the result? as far as i know, IN keyword act simply as OR keyword didnt Jona

Re: Maybe easy, maybe hard SELECT puzzle :)

2003-11-10 Thread Shane Allen
At 07:45 PM 11/7/2003, Jonathan Terhorst wrote: One way I have found to implement this is SELECT Table1.id from Table1 JOIN Features USING(id) WHERE Features.FeatureCode='A01' OR Features.FeatureCode='B02' GROUP BY Table1.id HAVING COUNT(*)=2; e.g. counting the duplications of id and selecting th

Re: Maybe easy, maybe hard SELECT puzzle :)

2003-11-07 Thread Leo
>But it I want all records from Table1 that have features 'A01' _and_ 'B02', >clearly >SELECT * from Table1 JOIN Features USING(id) WHERE >Features.FeatureCode='A01' AND Features.FeatureCode='B02' doesn't work. okay maybe this one is a more stupid and complex solution :) but i think it should wor

Maybe easy, maybe hard SELECT puzzle :)

2003-11-07 Thread Jonathan Terhorst
I can't figure out if this is actually challenging or if it's a stupid question. Table1 is a normal old relation that describes a bunch of objects: Table1 (id INT PRIMARY KEY NOT NULL, Name varchar(255), Size int) etc. Associated with each Table1 record is a variable-length of 3-byte alphanumeric