so my problem is that lets say i have 3 tables: "customerPerAdmin","admins","customers" and i'm joining them, but what if, customerPerAdmin.AdminID will be 0 for a certain user? what will happen that it will ignore the customer with adminID equals to zero, and i dont want that to happen, i want to set admins.FirstName and admin.LastName as empty.
customerPerAdmin Table:
ID AdminID CustomerID
40 20 49
41 25 48
42 20 50
43 0 51
and this is the query
SELECT SQL_CALC_FOUND_ROWS `customers.UniqID`,
`customerPerAdmin`.`AdminID`,
`customerPerAdmin`.`CustomerID`,
`customerPerAdmin`.`IsDeleted`,
`customerPerAdmin`.`pr`,
`admins`.`ID`,
`admins`.`GroupID`,
`admins`.`FirstName` AS adminFirstName,
`admins`.`LastName` AS adminLastName,
`admins`.`IsDeleted`,
`customers`.`FirstName`,
`customers`.`LastName`,
`customers`.`Phone`,
`customers`.`Email`,
`customers`.`GroupID`,
`customers`.`UniqID`,
`customers`.`Created`,
`customers`.`IsDeleted`,
`customers`.`ID`
FROM (`customers`)
JOIN `customerPerAdmin` ON `customers`.`ID`=`customerPerAdmin`.`CustomerID`
JOIN `admins` ON `admins`.`ID`=`customerPerAdmin`.`AdminID`
AND `customers`.`GroupID` = '8'
AND `customerPerAdmin`.`pr` = 0
GROUP BY `customers`.`ID`
ORDER BY `customers`.`ID` DESC LIMIT 20
so what will happen, it will only show me the IDs of 40,41,42 and not 43 because he cant relate it to an admin with ID of 0, because he is not exists. how can i still show ID 43 even if it not related?
thanks in advance.
INNER JOINtoLEFT OUTER JOIN