JOIN / Not existing records as blank cells in the results
JOIN / Not existing records as blank cells in the results
(OP)
hi
I have data in two tables.
NAMES
ID Name
1 FIRST
2 SECOND
...
CODES
ID CodeType Code
1 A xyz
1 B abc
1 C gfd
2 A xdz
2 B dca
3 A xvz
...
I want to join the two tables to get the records from NAMES with the Code of CodeType "C". if there is no record with the codetype c for a given ID a blank cell should appear, so that I can identify for which ID's the CodeType C is mising.
(as below for ID 2)
Result Example
ID Name Code
1 FIRST gfd
2 SECOND ----
...
Does anybody have any idea what should the sql code look like?
Please help!
I have data in two tables.
NAMES
ID Name
1 FIRST
2 SECOND
...
CODES
ID CodeType Code
1 A xyz
1 B abc
1 C gfd
2 A xdz
2 B dca
3 A xvz
...
I want to join the two tables to get the records from NAMES with the Code of CodeType "C". if there is no record with the codetype c for a given ID a blank cell should appear, so that I can identify for which ID's the CodeType C is mising.
(as below for ID 2)
Result Example
ID Name Code
1 FIRST gfd
2 SECOND ----
...
Does anybody have any idea what should the sql code look like?
Please help!
RE: JOIN / Not existing records as blank cells in the results
RE: JOIN / Not existing records as blank cells in the results
select NAMES.ID, NAME.NAMES, CODES.CODE from NAMES LEFT JOIN CODES on NAMES.ID=CODES.ID and CODTYPE='C'