How to Select Distinct Data from Table in MySQL or MariaDB - MySQL Developer Tutorial

How to Select Distinct Data from Table in MySQL or MariaDB

When you use distinct keyword in Select, it returns you distinct (different) values.  Below is the syntax you will use to get distinct values from MySQL Table.


Select distinct column1,column2,... from YourTableName;


Example :
Let's create customer table and then insert some rows in customer table.

CREATE TABLE `customer` (
  `idcustomer` int,
  `firstname` varchar(50)  NULL,
  `lastname` varchar(30)  NULL,
  `age` int(11) DEFAULT NULL,
  `phonenumber` char(11) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  `gender` char(1) NOT NULL
) ;



insert some values in table.

insert into customer(idcustomer,firstname,lastname,age,phonenumber,dob,gender)
values
(1,'Aamir','Ali',39,'505-4141969','1980-01-01','M'),
(2,'Aamir','Naz',39,'505-4141969','1980-01-01','M'),
(3,'Aamir','Shahzad',39,'505-4141900','1980-01-01','M');


Now let's say if you want to get the distinct or different values from first name column, you can run below  statement.


Select distinct firstname from customer;


The above query will return you only "Aamir".

Now let's say if you want to get distinct values for firstname and phonenumber, then you will get two values.


Select distinct firstname,phonenumber from customer;



57 comments:

  1. Computerized help has prepared it exaggeratedly. Would you be able to answer how it wound up conceivable? data science course in pune

    ReplyDelete
  2. Well, the most on top staying topic is Data Analytics. Data Analytics is one of the most promising technique in the growing world. I would like to add Data Analytics training to the preference list. Out of all, Data analytics course in Mumbai is making a huge difference all across the country. Thank you so much for showing your work and thank you so much for this wonderful article.

    ReplyDelete

  3. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. I would like to state about something which creates curiosity in knowing more about it. It is a part of our daily routine life which we usually don`t notice in all the things which turns the dreams in to real experiences. Back from the ages, we have been growing and world is evolving at a pace lying on the shoulder of technology. data science course will be a great piece added to the term technology. Cheer for more ideas & innovation which are part of evolution.

    ReplyDelete
  4. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
    pmp certification in bangalore

    ReplyDelete
  5. Such a very useful article. I have learn some new information.thanks for sharing.
    data scientist course in mumbai

    ReplyDelete
  6. You completed certain reliable points there. I did a search on the subject and found nearly all persons will agree with your blog.
    Data Analytics Course in Mumbai

    ReplyDelete
  7. Such a very useful Blog. Very interesting to read this article. I have learn some new information.thanks for sharing. know more about

    ReplyDelete
  8. Thanks for the informative and helpful post, obviously in your blog everything is good..
    ExcelR Data Analytics courses

    ReplyDelete
  9. Attend The PMP Certification From ExcelR. Practical PMP Certification Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The PMP Certification.
    ExcelR PMP Certification

    ReplyDelete
  10. Very nice blog here and thanks for post it.. Keep blogging...
    ExcelR data science training

    ReplyDelete
  11. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
    ExcelR data science course in mumbai

    ReplyDelete
  12. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. excelr data science

    ReplyDelete
  13. Great, i must say and thanks for sharing this informative post.I am really impressed that there is so much information about this subject that have been uncovered and you’ve done your best, MyAssignmenthelp.com is giving help to students who is stressed with their homework help and submit their assignment on time.we are already trusted by thousands of students who struggle to write their academic papers and also by those students who simply want Cost of Capital Homework Help to save their time and make life easy

    ReplyDelete
  14. This is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work. Admond Lee

    ReplyDelete
  15. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. Admond Lee

    ReplyDelete
  16. Very informative and well written post! Quite interesting and nice topic chosen for the post. My Assignment Help Au has been a pioneer within the Best Assignment Help on-line services and within the Australia and different countries ceaselessly for over Seven years. Make an order now for professional work, delivered on time and pure. You can email us at cs@Myassignmenthelpau.Com or Phone Number: +61-2-8005-8227.

    ReplyDelete
  17. When students help in online search they find the cost of essay writing very high. But at allassignmenthelp.com, we provide the best quality essays from students at low charge.
    best online essay writers

    professional college essay writers

    ReplyDelete
  18. To finish your project efficaciously, you must go for Assignment Help. services. How will you complete your assignment when you have no one to ask for help? Tough situation to deal with! This situation usually arises when students choose other countries to pursue their higher education especially the U.S.A. Getting the exact solution to your assignment related problem would not issue anymore. Browse our online portal and avail the best Online Assignment Help services as per your subject requirements.
    assignment help service
    assignment help company
    Help with assignment
    Help with assignment writing

    ReplyDelete
  19. Get best online Assignment help from top rated assignment help expert. We have 10+ years of experience in the field of assignment help. NZ Assignment Help are providing all the assignment help services for all college and university students. Our Assignment helpers NZ are giving on-time delivery guarantee with 100% plagiarism free content for all the assignment help.

    ReplyDelete
  20. You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. analysis report

    ReplyDelete
  21. Singapore essay writing service are giving you headaches? If you are worried because of your assignment work and submit on time, then you have to select Singapore Assignment Help Writing Services from us and you can easily overcome such situations.

    ReplyDelete
  22. I know that it's not exactly your topic but I have a question. what is questionnaire writing? I need to complete this task. I look for some valuable ideas.

    ReplyDelete
  23. Assignment Help allows scholars to get professional assignment writers’ assistance for writing effective assignments and homework. Avail of reliable online assignment writing services to boost your marks through on-time project submission.
    Assignment Help Online
    Online Assignment Help
    Assignment Helper

    ReplyDelete
  24. Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. If you're looking for CDR Report Help. You can email us at cs@needcdrreport.com or Phone Number: +61-2-8005-8227

    ReplyDelete
  25. You completed certain reliable points there. I did a search on the subject and found nearly all persons will agree with your blog.
    ExcelR Courses in Business Analytics

    ReplyDelete
  26. My friend promised to buy me a cup of coffee for referring him to your site. Thank you for coffee. Kindly keep updating us on new articles. These days, the most common pump for a shallow well is a jet pump. Jet pumps get mounted above the well, either in the home or in a good house, and draw the water up from the well through suction. Visit Best Shallow Well Pump for more.

    ReplyDelete
  27. My friend advised me to pay for literature review. I am studying at college. We are always assignd different tasks. On of th recent is to write a literature review. I do not hav tim for writing that is why I would better buy it.

    ReplyDelete
  28. Getassignmenthelponline.com is the world’s best online assignment service provider. They do as they say on the time so you can take help with any academic consultation or Assignment Help . Our team is always ready to serve according to your needs at any given time. Mathematics Assignment Help Law Assignment Help

    ReplyDelete
  29. Thank you for bringing to a halt my long search topic. I really benefited from your content. If you are experiencing trouble striking a balance between your busy academic life and handling your online classes, you can get help from a professional who will take online classes on your behalf. It doesn’t matter the kind of help you need, whether it is passing your exam, finishing your assignments or even the entire classwork, you can get help here at Online Class Help .

    ReplyDelete
  30. The information provided on the site is informative. Looking forward more such blogs. Thanks for sharing .
    Artificial Inteligence course in Nashik
    AI Course in Nashik

    ReplyDelete
  31. Plumbers On Call provides best services for your queries with Plumbing Services Near Me. We are active all day to provide plumbers at your homes! Visit Plumbers On Call.

    ReplyDelete
  32. Via reading, you got me engaged and guess what? I would like to learn more on that. This is what is considered an entertaining message. Read more- java assignment help

    ReplyDelete
  33. Traveling internationally and thinking to Book Delta Airlines Flights? Contact our experts they can help you to Book a Flight With Delta Airlines - an upgraded class at a discounted price.

    ReplyDelete
  34. When you want to buy discussion board post service it is important to appeal to reputable academic service company that offers a full range of assistance, including discussion board posts that are often an important component of your grade.

    ReplyDelete
  35. ABC assignment help is the most chosen place to get taxation assignment help in Australia. From where you can get 100% plagiarism free content and with money back guarantee with every order. Our support team is available 24×7 to provide you well formatted solutions for any subject.

    ReplyDelete
  36. My Assignment Help is an exceptional online assignment help providing adept Engineering help in my assignment help Australia We offer unsurpassable assignment solutions in various areas of engineering through a team of Ph.D. certified tutors having proficiency and knowledge in meeting University guidelines ensuring high score in every assignment, essay, coursework and dissertation writing task.

    ReplyDelete
  37. Thank you for sharing such a golden information will be your regular visitor. GIS (Geographical Information System) are basically systems of computers that are designed to collect, analyze, manage and share geographical and spatial data. Remarkably, almost all environmental applications today utilize GIS. In other words, GIS has gained wide applications in both research, management of wildlife, tracking specific species, informing agricultural practices among a tone of other different uses. Visit on GIS Assignment Help for more

    ReplyDelete
  38. Review and manage your bookings with the help of United Airlines Manage Booking helpdesk for hassle-free travelling experience.

    ReplyDelete
  39. Attend The Bangalore Digital Marketing Course From ExcelR. Practical Bangalore Digital Marketing Course Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Bangalore Digital Marketing Course.
    Bangalore Digital Marketing Course

    ReplyDelete
  40. Hello there, great stuff you’ve shared here I will be checking regularly for more articles. But wait! When it becomes hard to manage your online assignment, availing Online Assignment Help is the best choice. Many students often fail to submit their assignment before deadlines and end up scoring low grades because they didn’t have enough time to write the assignment given on time and satisfactorily. Visit Assignment Help . for assistance.

    ReplyDelete
  41. Students can take experts' assistance via Assignment Help services from the Australian service providers. Professional subject matter experts will help you to write your papers before the due dates even if you have issues of timing or quality content.
    My Assignment Help
    Assignment Help Online
    Online Assignment Help
    Assignment Help Australia

    ReplyDelete

  42. If you ever locked in a situation where you left the key in the door? If yes then give a call to Emergency LockSmith Near Me. We are available 24/7.

    ReplyDelete
  43. Are you suffering from the frustration of drainage clogging? Or irritated by leakage in the channel pipes? Call us to get Residential Plumbers Near Me.

    ReplyDelete
  44. wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now I am a bit clear. I’ve bookmarked your site. keep us updated. <a href="https://www.excelr.com/business-analytics-training-in-pune/”> ExcelR Courses </a>

    ReplyDelete

  45. The blog post is worth reading and I would like to appreciate your efforts for making us familiar with the features of purpose of narrative writing

    ReplyDelete
  46. Call at Auto Locksmith Near Me and one of our professional automotive locksmiths will be there to manage your lock-related requirements. Call now!!

    ReplyDelete
  47. Avail world-class printing technology on your system with Brother Wireless Printer Setup. Speak to us for help and support with Brother WiFi Printer Setup.

    ReplyDelete
  48. If you are not able to use a Canon Printer on your laptop or PC. You just need to give us a call and get help regarding Canon Printer Setup. Call Now!!

    ReplyDelete
  49. Call and speak to our specialist LockSmith Near Me anytime for your emergency or regular needs of home, office or elsewhere. We are available 24/7.

    ReplyDelete
  50. We can all make a consensus to the fact that law courses are more tedious and time consuming than most of the other academic courses. Courses get even more difficult when the students are tasked assignments on diverse specializations of law. In case you are required to prepare a corporate law assignment when you still cannot understand the administrative law, you do not have any other option but to make use of the Corporate Law Assignment Help assistance from the experts.
    Corporate Law essay assignment
    Corporate law assignment help
    Corporate governance expert
    Corporate governance essay
    Corporate law thesis
    Corporate governance dissertation

    ReplyDelete
  51. A great piece of writing! You have an efficient flair for high quality writing. I am highly impressed by your way of writing this content beyond words. I really have a lot of appreciation for your writing.
    SAP training in Kolkata
    SAP course in kolkata
    SAP training institute in Kolkata

    ReplyDelete
  52. You can take pride in the way you write such brilliant articles. It is reflected in the pattern of writing when a writer does the required homework to write quality material. Thank you so much for sharing this magnificent content.
    SAP training in Mumbai
    SAP course in Mumbai
    SAP training institute Mumbai

    ReplyDelete
  53. Access your flight information, update your itinerary, purchase add-ons, and more through Turkish Airlines Manage Booking helpdesk. Contact us now!

    ReplyDelete

  54. Use your printer smoothly with our Wireless Printer Offline services. We are there to solve all your issues quickly and instantly all the 24/7.

    ReplyDelete