Two sheets available
The first table is the boys ' table, which records the boys ' names and their spouses ' numbers.
The second table is the girl's Watch, which records the girl's name and her own number.
The first case: the host asked all the boys to come on stage and bring their spouse. At this point, regardless of whether the boy has a spouse to come to power, so is the boys table as the basis for the girls table
You can consider using the left connection
Cock Silk compared to the tragedy, in the girls table without his spouse, so gname and Gname.other are null. Gaofu certainly beautiful surrounded, so there are many lines of records.
The second case: the host invites all the girls to take the stage and bring their spouse. At this point, regardless of whether the girl has a spouse to come to power, so it is based on the female table as the benchmark boys table
You can consider using the left connection
Mei is also more tragic, there is no corresponding spouse in the boys table, so bname and Bname.other are null. As for Xiao Jiao, Xiao Zhi, Xiao Lin and Gaofu and Xiao Wang's relationship is more chaotic, there are many lines.
In the third case , the host invites all male and female students with a spouse to come to power, so that they can be connected.
Visible boy left Join girl on boy.other = Girl.other meaning: Found in girl table satisfies condition Boy.other = Girl.other rows are combined with the row in the Boy table, and the boy table does not have a matching row in the girl table to complement null.
The relationship between left and right connections and internal connections:
Left and right connections can be converted to each other. A LEFT JOIN B on condition equivalent to B left join A on condition
INNER JOIN a INNER JOIN B on condition is a LEFT join B on condition and b right join a on condition intersection.