Select DISTINCT over two columns
Results 1 to 2 of 2

Thread: Select DISTINCT over two columns

  1. #1
    Senior Member
    Join Date
    Apr 2005
    Posts
    1,339

    Select DISTINCT over two columns

    I have a table that's set up similar to this

    ID | ParentID | PostedTime

    I want to select rows where the ID and ParentID are distinct, so if I have ID 7 parent ID 7's are ignored, I want to then order it by PostedTime

    PHP Code:
    SELECT 
    DISTINCT t
    .IDt.ParentID
    FROM 
    `threads
    JOIN 
    `threads_tags_linksl ON t.ID l.ThreadID 
    I have this but it does not work

  2. #2
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,853
    How about just adding a where clause at the end?
    Code:
    WHERE t.ID != t.ParentID
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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