Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Getting all tables and columns that have a foreign key references to the given table's key

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I wrote a query for getting all tables and columns that have a foreign key references to the given table's key. Can you help me write it efficiently. Basically i want to avoid the outermost select statement which is written only to get the "referenced column name"..is there a way to get the referenced column name in the 2nd select statement thereby avoiding the outermost.

 
Master Rancher
Posts: 4663
49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first thought is, how do you know it'll make it more efficient? You might need to define "efficient" to answer that one.

My second is, unless you want the column_name to be part of the distinct, then you can't.
If it can be part of the distinct then you can simply put those joins and filters into the inner query.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic