Re: Tricky query

2006-08-04 Thread Morten
How about: SELECT DISTINCT `key`, COUNT(`key`) AS c FROM `table` WHERE `value` in (8,9,10) HAVING c=3; Clever! Thanks :-) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: Tricky query

2006-08-04 Thread Gerald L. Clark
Morten wrote: Hi, Given the table keyval(key int(11), val int(11)), I would like to be able to retrieve the keys for which a row exist for given X values. Example: key value 18 19 110 28 38 310 48 49 410 411 Given values 8, 9, 10 the query should t

Re: Tricky query

2006-08-04 Thread Gerald L. Clark
Morten wrote: Hi, Given the table keyval(key int(11), val int(11)), I would like to be able to retrieve the keys for which a row exist for given X values. Example: key value 18 19 110 28 38 310 48 49 410 411 Given values 8, 9, 10 the query should t

Re: Tricky query

2006-08-04 Thread Morten
Peter Brawley wrote: >Can this be expressed somewhat more elegantly than multiple EXISTS subqueries? >SELECT DISTINCT key FROM keyval outer >WHERE EXISTS (SELECT * FROM keyval inner >WHERE outer.key = inner.key >AND inner.val = 8) >AND EXISTS (SELECT * FROM keyval inner >WHE

Re: Tricky query

2006-08-04 Thread Peter Brawley
>Can this be expressed somewhat more elegantly than multiple EXISTS subqueries? >SELECT DISTINCT key FROM keyval outer >WHERE EXISTS (SELECT * FROM keyval inner >WHERE outer.key = inner.key >AND inner.val = 8) >AND EXISTS (SELECT * FROM keyval inner >WHERE outer.key = inner.key >

Re: tricky query

2003-10-10 Thread gerald_clark
This is a bit vague. How about showing what you have done, and how it is not what you wan't. Colleen Dick wrote: I am building a SELECT using a left join and I almost have what I want. One of the fields that gets sucked in from the left join is either null or has a value in it. if it is null I

Re: Tricky Query...

2002-04-05 Thread John Klein
[EMAIL PROTECTED] wrote: > > Here is a FABRICATED table I have TYPED OUT to demonstrate the information > that I'm looking for. > I'm looking for a single query that can produce: > > +--+--++---+ > | clientid | revision | name