Hello everyone. I am new in coding and db so i am facing a problem regarding of fetching the data from 3 tables. Please suggest or help me. Thanks in advance.

I was writing a query to fetch data from 4 tables i.e pat_table, test_table, doc_table, emp_table.
In pat_table there are columns tid, did, eid. Tid from test_table, did from doc_table and eid from emp_table.

Problem: when i am using join the data is fetching but if the pat_table contains one record then that record is displaying 10 times.

Please help me with this.


Try this sql code, it might help.

SELECT pt.tid, pt.did, pt.eid FROM pat_table
INNER JOIN test_table tt on tt.tid = pt.tid
INNER JOIN doc_table dt on dt.did = pt.did
INNER JOIN emp_table et on et.did = pt.did