0

I need to get all values from one table and check if they exists in other table, and brings data and NULL values.

These are my tables and I use Mysql 1-table CS

| id_m  | id_cs  |
|:-----:|:------:|
| 1     | 12     |
| 2     | 12     |
| 3     | 12     |
| 4     | 77     |

2-table HC

| id_m | id_cs |  idu  |
|:----:|:-----:|:-----:|
| 1    | 12    |   9   |
| 2    | 12    |   9   |
| 2    | 12    |   88  |

And the result I'm looking for is:

Bring me all CS.id_m from CS that exists and NOT exists in HC where HC.id_cs=12 and HC.idu=9

I need this:

| id_m | id_cs |  idu  |
|:----:|:-----:|:-----:|
| 1    | 12    |   9   |
| 2    | 12    |   9   |
| 3    | 12    |   NULL|

Thanks for your help

Jens
  • 67,715
  • 15
  • 98
  • 113

0 Answers0