Skip to content
Advertisement

SQL query to get both common and and non common data from 2 tables

Hi im looking for a query which will give me both common and non-common data in one query.

| ID       |  Assay         | req_ind     |
| -------- | -------------- |--------------
| 1.       | 123            | 0           |
| 2.       | 124            | 1           |
| 3.       | 125            | 1           |

Table 2

ID Assay
1 124

Result

required_missing required_present
125 124

Based on req_ind column from table 1 , if req_ind is 1 and the same assay is present in table 2 i want to list it as above.

required missing column can have multiple column.

Advertisement

Answer

With the data given this gives requested result:

output:

REQUIRED_MISSING REQUIRED_PRESENT
125 124
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement