Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2012
    Posts
    2

    Unanswered: retrive list of tables and columns

    I have a database name database1. I have column name "columnA"and 'columnB" in all tables.I have to retrive tables name and (columnA - columnB) of all tables like below

    table1 ( columnA - columnB)
    table2 ( columnA - columnB)
    table3 ( columnA - columnB)



    I have tried so far ,
    HTML Code:
    SELECT DISTINCT TABLE_NAME      FROM INFORMATION_SCHEMA.COLUMNS     WHERE COLUMN_NAME IN ('columnA','ColumnB')         AND TABLE_SCHEMA='Database1'
    any bit of info would be helpful

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    I think you are very close.

    Code:
    SELECT TABLE_NAME, GROUP_CONCAT(COLUMN_NAME ORDER BY COLUMN_NAME SEPARATOR ' - ')
          FROM INFORMATION_SCHEMA.COLUMNS
         WHERE COLUMN_NAME IN ('columnA','ColumnB')
             AND TABLE_SCHEMA='Database1'
       GROUP BY COLUMN_NAME;
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Aug 2012
    Posts
    2

    retrive list of tables and columns

    Thank you for your kind reply , being new i have to slowly work on it , thank you again ...

Posting Permissions

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