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;



69 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. 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
  3. 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
  4. Thanks for the informative and helpful post, obviously in your blog everything is good..
    ExcelR Data Analytics courses

    ReplyDelete
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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

  18. 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

  19. 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
  20. 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
  21. 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
  22. 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

  23. 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
  24. I have bookmarked your site for future reference. Good work. Most of the students come up to us for capsim homework help and always return satisfied. Our main purpose is to help you gain the best grades through your paper. We don’t have any concern with the reason behind asking for help; our main aim is delivering you the best capsim homework help. Captive simulation is named as capsim that is basically designed to teach students the different functional elements and the linking of decision and operational results. Moreover, it also develops the strong skills and commitments in the students to ensure academic and professional life success. Go ahead and reach out to us for Capsim simulation Help

    ReplyDelete
  25. Your blog is really awesome and I really enjoyed it. Students cannot graduate before submitting a high-quality capstone project. It is a basic requirement in all higher learning institutions that every student must embark on extensive research on a particular subject matter and present his or her findings in a professional way. Nursing students must write and present their standard capstone projects that will show their commitment to their academic achievements and their readiness to work in the public health sector. Reach out for Nursing Capstone Writers

    ReplyDelete
  26. It seems that such elementary things: balance, decency, and attentiveness. But with the existing characteristics of one or another, the person around you leads to the setting of circumstances or a positive mood. Life is filled with joy, happiness as well, the nuance of how you will apply for services order dissertation online. I turned for advice in despair that I will not have time to cope and I really received qualified help.

    ReplyDelete
  27. Thank you for this wonderful information share and excellent information providing by your article. Are you looking for assignment help services in Singapore? Do you require to finish your assignment? Perdisco Assignment Help is a well-liked assignment Acquire immediate Assignment Help before completion of time at a fair cost. Kindly visit the NeedAssignmenthelp website for more info.

    ReplyDelete
  28. Although some of the views expressed were extremely negative regarding American students I strongly beleive that American students should not only treat international students well and respectfully but also any other foreign visitor irregardless of ones place of origin.assignment expert

    ReplyDelete
  29. research paper writing help of any style: APA, MLA, etc. 24/7 Support, Full Confidentiality and 100% Plagiarism Free

    ReplyDelete
  30. This comment has been removed by the author.

    ReplyDelete
  31. Hey, Thanks for sharing this informative content with us.
    Mahindra Jeeto Price

    ReplyDelete
  32. i appreciate your quality stuff, that was really so useful and informative blog!
    Volvo Truck

    ReplyDelete
  33. Hey, Its Nice Blog thanks for sharing this with us

    Mahindra Yuvo

    ReplyDelete
  34. These tips are very useful for developers, especially for those who have knowledge about MySQL. They can improve their skills and earn a lot of money. Coursework writing services.

    ReplyDelete
  35. Ace Starlit Sector 152 Noida is an upcoming new residential project by ACE Group, Noida.ACE Starlit Noida Expressway presents 2/3 BHK luxury apartments which are innovatively planned dazzling an architectural splendor.If you have any queries please Visit our site:- Ace Starlit

    ReplyDelete
  36. You have received the proper place! you'll find the simplest custom boxes with logo here at custom boxes wholesale. we all know your desires for the merchandise of your packaging.

    ReplyDelete
  37. Looking for somebody to deliver the Nursing assignment help? Visit our platform for getting top-quality writing services. Our Ph.D. level professionals deliver top-notch projects within your desired time. Browse our website for knowing more details about the services.

    ReplyDelete
  38. Most students look for help with their assignments online. This is because of the great overload they have when studying. They have to complete assignments and sit for exams at the same time. Top Academic Writers are well aware of the tension and anxiety that comes with preparing for exams yet you have assignments to handle. You will always be chasing deadlines which makes you lack time to even enjoy the things you like doing. Read more on Academic Writers

    ReplyDelete
  39. Canon Pixma MG 2522 is an all-in-one inkjet printer equipped with multifunctional features like printer, scanner, and copier.
    Canon.com/ijsetup/mg2522 |
    Canon.com/ijsetup mg2522
    | microsoft365.com/setup

    ReplyDelete
  40. The information shared is really helpful to get to know about various facts and the information shared is rich in content. Looking forward to more informative blogs. absu cut off mark for business administration

    ReplyDelete
  41. visit your web page. It is really useful and easy to understand. Hope everyone get benefit. Thanks for sharing your Knowledge and experience with us. coffee beans australia

    ReplyDelete
  42. visit your web page. It is really useful and easy to understand. Hope everyone get benefit. Thanks for sharing your Knowledge and experience with us. coffee roasters sydney

    ReplyDelete
  43. Quickwitters is the leading assignment help provider in the world. We have the most professional assignment writers from Canada for all your academic needs. Our writers have been drawn from various universities of Canada.
    online assignment help Canada

    ReplyDelete
  44. The information you provided is very useful, thank you very much for sharing useful information with us. You can check the Azerbaijan visa requirement online. You can apply for a visa & pay Azerbaijan visa fee in just 5 minutes.

    ReplyDelete
  45. This comment has been removed by the author.

    ReplyDelete
  46. Very excellently written and perfect article, I found it extremely enlightening and informative. Thanks for sharing. is EkoUNIMED post utme form still on sale

    ReplyDelete
  47. Being a software engineer and SEO Expert currently living in the United States. My interests range from writing technology blogs to entrepreneurship. I am also interested in web development and programming.
    www.office.com/setup
    www.office.com/setup
    www.office.com/setup
    www.office.com/setup

    ReplyDelete
  48. It is a very informative article.Thankyou so much .Now You can easily apply to the Ukraine tourist visa express application system which takes just 5 minutes to apply and within 30 minutes you can get your e visa on your Email.

    ReplyDelete
  49. A canon pixma tr4520 setup and printer will most likely make your life more straightforward yet it may require a long time to comprehend it totally. Assuming you have purchased a Canon Pixma Tr4520 arrangement then you should set it up at first before you can begin with the printing system.

    ReplyDelete
  50. Our Cardiac Nursing Online Assignment assistance experts have obtained a higher Degree and are experienced medical professionals who can aid students with writing assignments on these and other subjects. Cardiac Nursing Assignment Help creates assignments by completing extensive study and applying effective strategies. Cardiac Nursing Assignment Help

    ReplyDelete
  51. This is an incredible blog post, thanks for sharing this article. I am truly motivated by you for blogging. free ielts nigeria past questions pdf

    ReplyDelete
  52. t is really useful and easy to understand. Hope everyone get benefit. Thanks for sharing your Knowledge and experience with us. Doodle Puppies

    ReplyDelete
  53. Hire the experts of British Dissertation help for outstanding Essay Writing Service . From providing customised solutions to choosing the topic to creating plagiarism-free work, our experts are capable of doing anything. Irrespective of the level and complexity of the task, our experts can help you overcome any hurdle and complete it on time.

    ReplyDelete
  54. Quick, quality and efficient proofreading service connect clients with an international audience. Acadecraft channels the content that appeals to bulk viewers' attention sitting in different parts of the globe. Native Proofreaders at Acadecraft have years of experience in delivering optimal proofreading solutions. The platform has expertise in proofreading technical, business, and academic content of any language.reliable fact checking serviceProfessional Abstract Writing Services

    ReplyDelete
  55. This comment has been removed by the author.

    ReplyDelete
  56. very informative and it has helped me a lot And what promotes my business visit our site: Toronto Boat Rentals

    ReplyDelete
  57. the most vital info for me.And i’m glad reading your article. But want to remark on some general things, The web site style is great, the articles is really nice Home Support

    ReplyDelete
  58. enjoyed reading your article. I found this as an informative and interesting post, so i think it is very useful and knowledgeable news

    ReplyDelete
  59. Your article is well written and simple to understand.You make excellent points.Thank you for sharing amazing blog.Nice.....

    ReplyDelete
  60. I am grateful to this blog for providing unique and helpful knowledge on this topic. Visit us for Getting free directory submission site list India. Thank You!

    ReplyDelete
  61. We are a group of skilled and enthusiastic developers, designers, and technical experts who have worked together to provide comprehensive support to our prestigious customers. We provide our customers with a complete interior, digital, and branding solution.
    Here our services laser cutting services in Gurugram, CNC laser cutting services in Gurugram, MDF jali cutting service in Gurugram, Jali cutting service in Gurugram etc.

    ReplyDelete
  62. always easy if you’ve ever had a dog. It can be downright frustrating.Dogs articles However, if you’re really willing to put in the time and effort, you’ll be able to have a pet who listens to every command with ease.

    ReplyDelete
  63. Assignment helper are instrumental in supporting students' educational success. They offer guidance and aid in tackling coursework, research, and homework assignments. By providing valuable insights, these helpers empower students to grasp challenging subjects and improve their academic performance. Their expertise is a valuable resource for those seeking academic excellence.




    ReplyDelete
  64. As an experienced management teacher and provider of assignment help services in the UK, I find this blog title intriguing. While focusing on MySQL or MariaDB queries, it's crucial to highlight the significance of efficient data management in contemporary business settings. Exploring techniques to select distinct data aligns with the core principles of management, emphasizing clarity and precision in decision-making. Incorporating management assignment help services could enrich the discussion, offering practical insights to students navigating database management challenges.

    ReplyDelete
  65. If you're feeling overwhelmed by your online trigonometry class and struggling to keep up with the demanding coursework, you might be considering PAY SOMEONE TO TAKE MY ONLINE TRIGONOMETRY CLASS for you. This option can provide you with the opportunity to focus on other responsibilities or subjects where you excel, while ensuring that your trigonometry grade does not suffer. By hiring a professional who is proficient in the subject, you can rest assured that assignments, quizzes, and exams will be completed accurately and on time, helping you achieve the grade you need without the added stress and time commitment.

    ReplyDelete