Reputation: 1537
I created a table which contains both primary as well as foreign keys. Now i wants to know what are the tables which refers my table element as foreign key.
For example, student
is a table which contains id (primary key), name
element. And standard
is an another table which contains class_id (primary key), and stud_id (Foreign key refers student table id field)
. When i give student table and id field as input, it returns standard table as output. Please suggest me how can i achieve this???
Upvotes: 3
Views: 12700
Reputation: 29
ok, few things are missing, you didn't tell how you are trying to achieve this, what operating syatem you are using, you want to do it using script? if so what langauge, what dbms are you using? Let me know and you answer will be ready
ok here it is, you can delete last line if you prefer
SELECT standard.ID
FROM student INNER JOIN standard ON student.ID = standard.stud_id
GROUP BY standard.ID;
Upvotes: 0
Reputation: 15603
Well here is the link of solution of your problem.
How do I see all foreign keys to a table or column?
mysql innodb: describe table does not show columns references, what does show them?
check it.
Upvotes: 2