Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8113647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:53:43+00:00 2026-06-06T02:53:43+00:00

There are two tables Table 1 select * from manage_tcp; +—-+———-+——–+ | id |

  • 0

There are two tables

Table 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)

Table 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)

I’d like to compare those two tables above and to get the results in table 1 but not in table 2 like: (this is the result i want)

+----+----------+--------+
| id | services | statut |
+----+----------+--------+
|  2 |     1433 | up     |
|  3 |     3389 | down   |
|  3 |     1433 | down   |
+----+----------+--------+

I’ve tried

SELECT a.*,b.* 
FROM manage_tcp as a 
LEFT JOIN manage_host as b 
USING(id,statut) 
WHERE b.id is null;

but I got

+----+----------+--------+
| id | services | statut |
+----+----------+--------+
|  3 |     3389 | down   |
|  3 |     1433 | down   |
+----+----------+--------+

it’s not what I want.

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:53:45+00:00Added an answer on June 6, 2026 at 2:53 am

    Try this: (assume the comparison column are id and statut)

    SELECT a.id, a.services, a.statut
        FROM manage_tcp a
        WHERE NOT EXISTS(SELECT b.id FROM manage_host b WHERE b.id=a.id AND b.statut=a.statut)
    UNION
    SELECT a.id, (SELECT services FROM manage_tcp WHERE id=a.id ORDER BY id LIMIT 1), a.statut
        FROM manage_tcp a 
        GROUP BY a.id, a.statut HAVING COUNT(1)>1
    

    The first query will produce result from table a where not in table b.

    The second, after UNION, will produce result for id that appear twice in table a.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to merge two SELECT statements. There are two tables in my database,
There are two tables Table A id column_a 01 abc 01 abc 02 abc
There are two tables: CREATE TABLE STORE ( ID INTEGER NOT NULL, MEDICINE_ID INTEGER
I've two master tables Org & Item and then there's an OrgItem table.I have
There are two tables, categories and books and I'd like to select all books
Thank you for your attention. There are two INNODB tables: Table authors id INT
There are two tables: Posts and Tags. There is another table called PostsTags having
I have two tables. I am trying to find rows in one table which
Say there are two tables: TABLE A messageID / Message / More.. 1 /
I have next input data, There are two tables create table Courses( id number(19)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.