MySQL get referenced table name

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Leshij
Forum Newbie
Posts: 2
Joined: Fri Feb 22, 2008 12:14 pm

MySQL get referenced table name

Post by Leshij »

Hi!
For example, i have some field marked as mysql_field_name($r, $i). I called mysql_field_flags() and I found out that this is "Multiple_Key'. So, this is a FOREIGN KEY to some table. How can I find out that table name?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: MySQL get referenced table name

Post by califdon »

Leshij wrote:Hi!
For example, i have some field marked as mysql_field_name($r, $i). I called mysql_field_flags() and I found out that this is "Multiple_Key'. So, this is a FOREIGN KEY to some table. How can I find out that table name?
I don't think you can. That information isn't stored anywhere in MySQL.
Leshij
Forum Newbie
Posts: 2
Joined: Fri Feb 22, 2008 12:14 pm

Re: MySQL get referenced table name

Post by Leshij »

But, somehow, MySQL recognizes, that this field references to some table, that means, that this info IS stored somewhere.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: MySQL get referenced table name

Post by califdon »

Leshij wrote:But, somehow, MySQL recognizes, that this field references to some table, that means, that this info IS stored somewhere.
No, you supply that information in your query. Try doing a JOIN or a WHERE without explicitly providing the key relationships.
Post Reply