'Group returned result by mysql
I have the following table
table x
labref name repeat_status
111 L 1
111 L 1
111 K 1
111 K 1
111 L 2
111 L 2
111 M 1
111 M 1
The result that i need is
labref name repeat_status
111 L 1
111 L 2
111 K 1
111 M 1
I have tried this query but it does not bring the result, needs tweaking
SELECT name, repeat_status
FROM `x`
WHERE labref = '111'
GROUP BY repeat_status;
suggestions!
Solution 1:[1]
SELECT name, repeat_status
FROM `x`
WHERE labref = '111'
GROUP BY name ,repeat_status;
Solution 2:[2]
select DISTINCT labref ,name, repeat_status
FROM x
WHERE labref = '111'
This query would get the result you are looking for.
Solution 3:[3]
SELECT labref,name,repeat_status
FROM `x`
WHERE labref = '111'
GROUP BY name,repeat_status;
Solution 4:[4]
SELECT name, repeat_status
FROM `x`
WHERE labref = '111'
GROUP BY name,repeat_status;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | echo_Me |
Solution 2 | Sonam |
Solution 3 | |
Solution 4 | Neeraj Kumar Gupta |