There is a table Main
( key
int, filed1
int, ...) and subordinateFields
( id
int, name
varchar (256)).
There is a relationship Main
. filed1
-> Fields
. id
(or how to properly designate? "<-"?).
It may be that Main
. filed1
= NULL
, i.e. Not for all records of the main table is. record in the subordinate table.
Task : you need to display all records Main
: Main
. key
AS key
, Fields
. name
AS Name
.
For Main
entries. filed1
= NULL
, in the Name
column output NULL
.
UPD
I know how to display only those records for which there is a subordinate record and how to display only those records for which there is no subordinate record. And how to display all these records in one query?
Decision
The solution was simple:
select Main
. key
, Fields
. Name
from Main
left join Fields
on Main
. field1
= Fields
. id