Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2006
    Posts
    50
    Thanks
    2
    Thanked 0 Times in 0 Posts

    MySQL Query without repeating same data

    Hello there,
    Each piece of data in my table has a category field associated with it, making multiple items with the same categories. I want to create a MySQL query that will only grab the different categories associated with the data in the table.

    example data
    Name Field: Picture 1, Category Field: Trip
    Name Field: Picture 2, Category Field: Park
    Name Field: Picture 3, Category Field: Park
    Name Field: Picture 4, Category Field: Trip
    Name Field: Picture 5, Category Field: Trip
    Name Field: Picture 6, Category Field: Birthday
    Name Field: Picture 7, Category Field: Trip
    Name Field: Picture 8, Category Field: Birthday

    Query would only display: Trip, Park, Birthday


    Any ideas?

    Thanks!
    Kyle

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    select distinct categoryField from table

    or

    select categoryField from table group by categoryField


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •