SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query help with distinct

    HI,

    I have a simple query

    Code:
    SELECT DISTINCT alt, galID FROM cfm_gallery LIMIT 12
    Which works great, but I also want to add another field to the query

    photo

    But I don't want that field to be distinct, how do I do this?

    Thanks

    Chris

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Why don't you want the photo field to be distinct?

  3. #3
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As the galID holds different values such as 54, 55, 56

    But the photo contains the filename, which is sometimes called the same thing

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    So?
    Code:
    SELECT DISTINCT alt, galID, photo FROM cfm_gallery LIMIT 12
    will give you all alt-galID-photo values without duplicates.
    galID 54 with photo 'john' and galID 55 with photo 'john' will both be selected.

    If this isn't what you want, then please post an example of the data present in your table, and the result you'd like the query to have.


Bookmarks

Posting Permissions

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