2つのテーブルがあります
表1
select * from manage_tcp;
+----+----------+--------+
| id | services | statut |
+----+----------+--------+
| 2 | 1433 | up |
| 2 | 3389 | up |
| 3 | 3389 | down |
| 3 | 1433 | down |
| 9 | 3389 | up |
| 8 | 3389 | up |
| 7 | 1433 | up |
| 6 | 3389 | up |
| 5 | 3389 | up |
| 4 | 3389 | up |
| 10 | 1433 | up |
| 11 | 1433 | up |
| 12 | 3389 | up |
| 13 | 1433 | up |
| 14 | 3389 | up |
| 15 | 1433 | up |
| 16 | 3389 | up |
| 17 | 1433 | up |
| 18 | 3389 | up |
| 19 | 1433 | up |
| 20 | 3389 | up |
| 21 | 1433 | up |
| 24 | 1433 | up |
| 23 | 3389 | up |
| 25 | 3389 | up |
| 26 | 1433 | up |
| 29 | 1433 | up |
| 28 | 3389 | up |
| 30 | 3389 | up |
| 31 | 80 | up |
| 32 | 3389 | up |
| 33 | 80 | up |
| 34 | 3389 | up |
| 35 | 80 | up |
+----+----------+--------+
34 rows in set (0.00 sec)
表2
mysql> select * from manage_host;
+----+------------+-------------+--------+-------+--------------+----------+------+
| id | uptime | type | statut | group | thresold_ref | thresold | mail |
+----+------------+-------------+--------+-------+--------------+----------+------+
| 2 | 277248529 | win2003.png | up | 4 | 1 | 0 | NULL |
| 3 | 277277471 | win2003.png | prob | 4 | 1 | 0 | NULL |
| 4 | 346159833 | win2003.png | up | 4 | 1 | 0 | NULL |
| 5 | 930205491 | win2003.png | up | 5 | 1 | 0 | NULL |
| 6 | 3805663007 | win2003.png | up | 5 | 1 | 0 | NULL |
| 7 | -1 | win2003.png | up | 4 | 1 | 0 | NULL |
| 8 | 29413867 | win2003.png | up | 5 | 1 | 0 | NULL |
| 9 | 981986401 | win2003.png | up | 5 | 1 | 0 | NULL |
| 10 | -1 | win2003.png | up | 5 | 1 | 0 | NULL |
| 11 | -1 | win2003.png | up | 5 | 1 | 0 | NULL |
| 12 | 2230787611 | win2003.png | up | 7 | 1 | 0 | NULL |
| 13 | -1 | win2003.png | up | 7 | 1 | 0 | NULL |
| 14 | 1004161923 | win2003.png | up | 8 | 1 | 0 | NULL |
| 15 | -1 | win2003.png | up | 8 | 1 | 0 | NULL |
| 16 | 1592294954 | win2003.png | up | 8 | 1 | 0 | NULL |
| 17 | -1 | win2003.png | up | 8 | 1 | 0 | NULL |
| 18 | 1449216250 | win2003.png | up | 4 | 1 | 0 | NULL |
| 19 | -1 | win2003.png | up | 4 | 1 | 0 | NULL |
| 20 | 3461945234 | win2003.png | up | 4 | 1 | 0 | NULL |
| 21 | -1 | win2003.png | up | 4 | 1 | 0 | NULL |
| 23 | 3461946968 | win2003.png | up | 4 | 1 | 0 | NULL |
| 24 | -1 | win2003.png | up | 4 | 1 | 0 | NULL |
| 25 | 3462022562 | win2003.png | up | 4 | 1 | 0 | NULL |
| 26 | -1 | win2003.png | up | 4 | 1 | 0 | NULL |
| 35 | 3318333401 | win2003.png | up | 6 | 1 | 0 | |
| 28 | 3461879984 | win2003.png | up | 4 | 1 | 0 | NULL |
| 29 | -1 | win2003.png | up | 4 | 1 | 0 | NULL |
| 30 | 1872950109 | win2003.png | up | 6 | 1 | 0 | NULL |
| 31 | 1872950125 | win2003.png | up | 6 | 1 | 0 | NULL |
| 32 | 1955232033 | win2003.png | up | 6 | 1 | 0 | NULL |
| 34 | 3318333401 | win2003.png | up | 6 | 1 | 0 | |
| 33 | 1955232049 | win2003.png | up | 6 | 1 | 0 | NULL |
+----+------------+-------------+--------+-------+--------------+----------+------+
32 rows in set (0.00 sec)
上記の2つのテーブルを比較して、次のようなテーブル2ではなくテーブル1の結果を取得したいと思います(これは私が望む結果です)
+----+----------+--------+
| id | services | statut |
+----+----------+--------+
| 2 | 1433 | up |
| 3 | 3389 | down |
| 3 | 1433 | down |
+----+----------+--------+
私はもう試した
SELECT a.*,b.*
FROM manage_tcp as a
LEFT JOIN manage_host as b
USING(id,statut)
WHERE b.id is null;
しかし、私は得ました
+----+----------+--------+
| id | services | statut |
+----+----------+--------+
| 3 | 3389 | down |
| 3 | 1433 | down |
+----+----------+--------+
それは私が望むものではありません。
どうもありがとう!