Bathakarai
Bathakarai

Reputation: 1537

How to find table dependencies in mysql

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

Answers (2)

Khushwant Singh
Khushwant Singh

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

Related Questions