hey guys. I've always had problems when it comes to getting data from multiple tables in a database and so now I have another one.
I want to get data from 3 different tables: contact1, child1 and spouse1.
columns in contact1 where i want to get data from:
contact_id | fullname |
columns in spouse1 where i want to get data from:
spouse_id | s_fullname | sspouse_name |
sspouse_name(spouse1) = fullname(contact1)
i want to get spouse_id and s_fullname
columns in child1 where i want to get data from:
child_id | c_fullname | primaryparent | secondaryparent |
primaryparent(child1) = fullname(contact1)
secondaryparent(child1) = s_fullname(spouse1)
Im trying to get these datas because I have a table to display a list of contacts and their dependents so something like this:
Name | Spouse | Children |
fullname | s_fullname | c_fullname |
fullname | s_fullname | c_fullname |
currently i have only one record for each table(allf filled up with the necessary values).
i tried this in the server(phpmyadmin):
SELECT
c.contact_id,c.fullname,
s.spouse_id,s.s_fullname,s.sspouse_name,
ch.child_id,ch.c_fullname,ch.primaryparent,ch.secondaryparent
FROM contact1 c
INNER JOIN spouse1 s ON c.fullname = s.sspouse_name
LEFT JOIN child1 ch ON c.fullname = ch.primaryparent
returned :
mysql returned an empty result set
even adding the WHERE clause produced the same result.
what am i doing wrong here?