Jump to content

[SOLVED] Compare two tables, delete non matching values MYSQL


Recommended Posts

For some reason, I am struggling with the query, maybe someone can help me out.  Here is what I'm trying to do:

 

Before Query:

 

      Table 1                  Table 2

  ID  |  DATE              ID | DATE

-------------              -----------

1        2007-01-01      1      2007-01-01 

2        2007-01-01      1      2007-01-01 

3        2007-01-01      2      2007-01-01 

4        2007-12-12      3      2007-01-01 

5        2007-01-01      3      2007-01-01 

                                4      2007-12-12

 

After Query:

 

Table 1                  Table 2

  ID  |  DATE              ID | DATE

-------------          -----------

1        2007-01-01      1      2007-01-01 

2        2007-01-01      1      2007-01-01 

3        2007-01-01      2      2007-01-01 

4        2007-12-12      3      2007-01-01 

                                3      2007-01-01 

                                4      2007-12-12

 

I need the query to take the values in Table 1 and in Table 2 and compare them.  If Table 1 has an ID that doesn't exist anywhere Table 2 with the same date, then Table 1 needs to have that row removed. 

 

Any help would be greatly appreciated.  Please let me know if I need to elaborate. 

 

Ryan

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.