I have a mytable table as shown below;
βββββββββββ¦βββββββ¦ββββββ β product β tag β lot β β ββββββββββ¬βββββββ¬ββββββ£ β 1111 β 101 β 2 β β 1111 β 102 β 5 β β 2222 β 103 β 6 β β 3333 β 104 β 2 β β 4444 β 101 β 2 β β 5555 β 101 β 2 β β 5555 β 102 β 5 β β 6666 β 102 β 2 β β 6666 β 103 β 5 β β 7777 β 101 β 2 β β 7777 β 102 β 5 β β 7777 β 103 β 6 β β 8888 β 101 β 1 β β 8888 β 102 β 3 β β 8888 β 103 β 5 β β 9999 β 101 β 6 β β 9999 β 102 β 8 β βββββββββββ©βββββββ©ββββββ
I have input 101 , 102 . I want the result to be as follows:
2,5 6,8
I have a query like:
select group_concat(lot order by lot) from `mytable` group by product having group_concat(tag order by tag) = '101,102';
It returns:
2,5 2,5 6,8
Instead of two 2,5 , I want only one, avoiding duplicate lines. How can i do this?
Here is the fiddle http://sqlfiddle.com/#!9/7a78bb/1/0
source share