Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2006

    Unanswered: Combining Records

    Hi Folks!

    I have a database table tblobjects like this:

    object_name, reference_id

    a 1
    a 2
    a 3
    a 4

    b 2
    b 3
    b 1
    b 4

    c 2
    c 4
    c 5
    c 6

    d 2
    d 4
    d 5
    d 6

    I now would like to have a SQL query which gives me the number of
    unique object and reference combinations, like this:


    d shouldn't be displayed, because it's equal to c. The problem is also that a sequence of object references is
    also important. So, for instance, object a shouldn't be equal to object b. The solution should also work is MS SQL and Mysql.

    Any ideas how can I do this?


  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    your data model is seriously flawed

    there is no such thing as sequence in a relational database

    therefore a is exactly the same as b

    you may need to introduce a sequence column | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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