2

mysql like that

=======================
| id    |  name       |
| 1     | jhon        |  
| 2     | sarah       |
| 3     | suzan       |
| 4     | jhon        |
| 5     | ahmed       |
=======================

my expected result is

sarah
suszan
ahmed

want to remove jhon or any value name are duplicated i tried to use

SELECT * FROM  table WHERE id={$id} GROUP BY name

but it's only displaying the duplicated values

2 Answers 2

2

Use HAVING

SELECT `name` FROM `table` GROUP BY `name` HAVING COUNT(`name`) = 1
Sign up to request clarification or add additional context in comments.

Comments

0

To get unique values, you can use below :

// This will return unique values

SELECT DISTINCT `name` FROM `table`;

1 Comment

He's not asking for distinct but for name having count 1 as in @Talgat answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.