I am using this query.
select * from customers E JOIN `customer_p` D ON (E.ID = D.`P_ID`)
Here E.ID is primary key of customers table and p_ID is foreign key of customer_p This query fetches only those result in which primary key (ID) of customers table is present as foreign key (P__ID) of customer_p table and skips rest rows/data from customers table.
I want to fetch all date of customers table whether or not primary key (ID) do match with foreign key (P__ID). How can I do this?
Advertisement
Answer
Use LEFT JOIN instead of JOIN to get all rows in customers. see https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins