When I run this SQL query, it should not show the result if ShopID, company is null
It returned null because member_id can not be found in the Shop table.
SELECT username, group_id, T.company, T.ShopID
FROM members AS M
LEFT JOIN Shop AS T ON T.member_id = M.member_id
WHERE M.member_id =15
How can that be solved?
You can use a RIGHT or INNER join instead of a LEFT join.
LEFT JOIN means return the left-hand side of the join even if there’s no right-hand side.
RIGHT JOIN means return the right-hand side of the join even if there’s no left-hand side. INNER JOIN means only return a record if both sides of the join have a record.