2

I have a table server like this;

Model | Brand
-------------------
M4000 | Dell
S4000 | Hp
S3500 | Hp
S6500 | Sun

I want to display different data from the 'Brand' field which means I don't want the second 'Hp' data to display again. How do I do that?

1
  • 2
    DISTINCT in MySQL may help here Commented Apr 19, 2012 at 7:44

8 Answers 8

6
SELECT DISTINCT Brand FROM tableName
Sign up to request clarification or add additional context in comments.

1 Comment

No problem, Mister Abdullah. Feel free to mark my answer as accepted if it answered your question.
1

Utilize DISTINCT:

select distinct (brand) from table

Comments

0
SELECT DISTINCT Brand FROM table

Comments

0

You can use the 'GROUP BY' keyword, but in this case you get just one data for each Brand (the first 'Model' data).

Else you can use 'DISTINCT' and you get many same 'Brand' values.

PS: I'm French sorry for my english....

Comments

0

Try this :

SELECT Model FROM tableName GROUP BY Brand

Comments

0

For example purposes let's assume your table name is mod_brand, then this SQL statement will group together by brand:

select m.*
from   mod_brand m
group  by Brand;

Comments

0

Using distinct will cause only once instance of Brand to display, like this. So, use

select distinct Brand from your_table;

Comments

0

Try this:

select distinct brand from tablename

Otherwise, try this:

select brand,group_concat(model) from table group by brand

Comments

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.