0

I have table named as test like

+------+------+-------+-------+
| id   | date | xname | yname |
+------+------+-------+-------+
| 1001 | 2015 | A     | A     |
| 1001 | 2014 | B     | Y     |
| 1002 | 2016 | A     | A     |
| 1001 | 2016 | B     | Y     |
| 1002 | 2014 | A     | A     |
+------+------+-------+-------+

And i want unique values from each column like

+------+------+-------+-------+
| id   | date | xname | yname |
+------+------+-------+-------+
| 1001 | 2014 | B     | Y     |
| 1002 | 2016 | A     | A     |
+------+------+-------+-------+
Bhushan Ahire
  • 79
  • 1
  • 6
  • 4
    Please edit the question and show the results that you want. – Gordon Linoff Feb 19 '16 at 12:15
  • We need to know **what unique value** you want, so please do as Gordon suggests or nobody will bother answering this question as it is only possible to guess at what you want. Please read [How to ask a good question](http://stackoverflow.com/help/how-to-ask) And [the perfect question](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) – RiggsFolly Feb 19 '16 at 12:28
  • Possible duplicate of [MySQL SELECT DISTINCT multiple columns](http://stackoverflow.com/questions/12188027/mysql-select-distinct-multiple-columns) – cdaiga Feb 19 '16 at 12:28
  • The DISTINCT keyword can be used to return only distinct (different) values. – Murad Hasan Feb 22 '16 at 12:26

1 Answers1

0
SELECT '1001' id
     , '2014' date
     , 'B' xname
     , 'Y' yname
 UNION 
SELECT '1002' 
     , '2016'
     , 'A'
     , 'A';
Strawberry
  • 33,750
  • 13
  • 40
  • 57