Table person
id | name | age
---------------
1 | max | 30
2 | sue | 28
3 | ada | 22
4 | sam | 31
5 | test | 0
Table male
id | personid
--------------
1 | 1
2 | 4
3 | 5
Table female
id | personid
--------------
1 | 2
2 | 3
3 | 5
How can I get an output like this? So a column (gender) should be related to the presence in another table and the output.
name | gender
-------------
max | M
sue | F
ada | F
sam | M
test | X