List:General Discussion« Previous MessageNext Message »
From:hsv Date:November 22 2012 11:56pm
Subject:Re: Basic SELECT help
View as plain text  
>>>> 2012/11/22 14:30 +0000, Neil Tompkins >>>>
I'm struggling with what I think is a basic select but can't think how to
do it : My data is

id,type

1000,5
1001,5
1002,2
1001,2
1003,2
1005,2
1006,1

From this I what to get a distinct list of id where the type equals 2 and 5

Any ideas ?
<<<<<<<<
This ugly one, which generalizes:

select id,group_concat(type) AS tl from the_table group by id having find_in_set('2',tl)
and find_in_set('5',tl)

Ugly becaus it involves so much converting between number & string.

Thread
Basic SELECT helpNeil Tompkins22 Nov
  • Re: Basic SELECT helpMike OK22 Nov
  • Re: Basic SELECT helpmarek gutowski22 Nov
    • Re: Basic SELECT helpNeil Tompkins22 Nov
      • Re: Basic SELECT helpBenaya Paul22 Nov
        • Re: Basic SELECT helpNeil Tompkins22 Nov
  • RE: Basic SELECT helpJason Trebilcock22 Nov
    • Re: Basic SELECT helpMichael Dykman22 Nov
      • Re: Basic SELECT helpNeil Tompkins22 Nov
        • Re: Basic SELECT helpMichael Dykman22 Nov
      • Re: Basic SELECT helpNeil Tompkins22 Nov
      • Re: Basic SELECT helpNeil Tompkins22 Nov
      • Re: Basic SELECT helpNeil Tompkins22 Nov
  • Re: Basic SELECT helphsv22 Nov
Re: Basic SELECT helpMogens Melander22 Nov
Re: Basic SELECT helpMogens Melander22 Nov
  • Re: Basic SELECT helpMichael Dykman22 Nov
Re: Basic SELECT helphsv23 Nov
  • Re: Basic SELECT helpShawn Green19 Dec