Page 1 of 1
MySQL get referenced table name
Posted: Fri Feb 22, 2008 12:22 pm
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?
Re: MySQL get referenced table name
Posted: Fri Feb 22, 2008 1:25 pm
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.
Re: MySQL get referenced table name
Posted: Fri Feb 22, 2008 2:19 pm
by Leshij
But, somehow, MySQL recognizes, that this field references to some table, that means, that this info IS stored somewhere.
Re: MySQL get referenced table name
Posted: Fri Feb 22, 2008 3:08 pm
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.