A SQL query on the existence of columns in two tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cuqsy0
    New Member
    • Apr 2012
    • 22

    A SQL query on the existence of columns in two tables

    Hi,

    A SQL query on the existence of columns in two tables. For example, tables A and B have many columns, respectively, such as COLA1, COLA2, COLAM, and COLB1, COLB2, COLBN. I wish to write a SQL query to check whether Table C's columns (COLC1, COLC2, COLCL) exist in Table A and B. If possible, I prefer not to answer the question with the information_sch ema.columns, but use the joins/subqueries between A and B.

    Thanks in advance!

    -CUQ
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    You can't do it with joins on A and B because you don't know which columns to do the joins on.information_ schema is best for this. Why don't you want to use it?

    Comment

    • cuqsy0
      New Member
      • Apr 2012
      • 22

      #3
      Originally posted by r035198x
      You can't do it with joins on A and B because you don't know which columns to do the joins on.information_ schema is best for this. Why don't you want to use it?
      Thank you for the advice. How can I do it with information_sch ema ?

      Comment

      Working...