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.

  • 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?


  • syscat is DB2

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

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