query to get a unique pair of details from db

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rekchris
    New Member
    • May 2007
    • 1

    query to get a unique pair of details from db

    I have a table MyTable with multiple fields.
    eg : ip, gw,id where id is the primary key
    I need unique ip,gw pairs
    eg:
    ip gw id
    1.1 a 1
    2.1 b 2
    3.1 c 3
    1.1 a 4

    I need to eliminate duplicate pairs ie 1.1 a
    I am not able to build such a query
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Moving this thread to the MySQL Forums.
    Please try to refrain from posting questions in the Article section.

    MODERATOR

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi, and welcom to TSDN.

      Do you need your ID column?
      If not you could make the other two fields act as Primary Key. Then they would not be able to accept duplicate values.

      E.g:
      [Code=SQL]
      CREATE TABLE myTable
      (
      colA VARCHAR(255) NOT NULL,
      colB INT NOT NULL,
      Primary Key(colA, colB)
      )
      [/CODE]

      Comment

      Working...