Reputation:
I am having a table "example". In that table I am having 3 columns say name,id,dept. Here except dept other two is unique i.e,. records should not be repeated.
f | 6 |mechanical
here i want to return
i tried with using distinct keyword but it returns nothing.
Thank you in advance
Upvotes: 0
Views: 35
Reputation:
I finally found answer to my question my senior helped me out instead of using distinct we have to use group by.Code is SELECT * FROM example GROUP BY dept;
Upvotes: 1
Reputation: 329
you must define an additional column for your table that it has a same value for your required outputs. then you can select all from table that has value in new column. hope you know what i mean.
Upvotes: 0
Reputation: 2047
Use the Distinct
keyword to perform that query. For example:
SELECT DISTINCT <column_name> FROM <table_name>;
If it returns nothing, you probably have some errors on your code or database.
Upvotes: 0