Home Page for the TeradataForum
 
https:

Archives of the TeradataForum

Message Posted: Wed, 28 Feb 2007 @ 20:33:17 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Is there any way to find all tables which have two particular column in a database
 
From:   Dieter Noeth

Murugesan Arumugam wrote:

  For example I need to find all tables which are having art_no and client_cd as field using dcb.columns in a single Query using inner join.  


     select
        t1.databasename, t1.tablename
     from dbc.columns as 1t1
     join dbc.columns as 1t1
     on t1.databasename = t2.databasename
     and t1.tablename = t2.tablename
     where
        t1.columnname = 'art_no'
     and
        t2.columnname = 'client_cd'

     or without join:
     select
        databasename, tablename
     from dbc.columns
     where
        t1.columnname in ('art_no', 'client_cd')
     group by 1,2
     having count(*) = 2

Dieter



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 28 Jun 2020