Two unique key in one table

  • I have two unique keys in one table and I want to write a query that connects me to two unique keys and displays them in one record. Right now, the question returns 2 records to me where unique key = ID in the first and unique key = PM in the second record. And I would like to have one record unique key = ID. I want to try the Procedure described here but I'm scared that I am doing wrong. Can someone give some insight here?

    i.COLNAMES  AS CCOLUMNS, C.TABNAME
    FROM syscat.columns C
    JOIN SYSCAT.INDEXES I ON I.TABNAME = C.TABNAME
    WHERE UNIQUERULE IN ('P','U')
  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • This was removed by the editor as SPAM

  • Piyushbhatt wrote:

    I have two unique keys in one table and I want to write a query that connects me to two unique keys and displays them in one record. Right now, the question returns 2 records to me where unique key = ID in the first and unique key = PM in the second record. And I would like to have one record unique key = ID. I want to try the Procedure described here but I'm scared that I am doing wrong. Can someone give some insight here?

    i.COLNAMES  AS CCOLUMNS, C.TABNAME
    FROM syscat.columns C
    JOIN SYSCAT.INDEXES I ON I.TABNAME = C.TABNAME
    WHERE UNIQUERULE IN ('P','U')

    This does not run on my SQL Server system (even when prepended with SELECT). Which database platform are you using?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • syscat is DB2

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply